Thursday, 22 August 2013

How to Left and Right Align labels on UITableCell

How to Left and Right Align labels on UITableCell

I need a table layout like this screenshot
Screen:1
but i am getting like this
Screen:2
after scrolling the table it becomes like the first screen as required but
initially its like screen 2.
My code for this in cellForRowAtIndexPath method is
UILabel *titleLabel = (UILabel *) [cell viewWithTag:1];
titleLabel.backgroundColor =[UIColor whiteColor];
if (indexPath.row % 2) {
NSLog(@"Odd Cell");
[titleLabel setFrame:CGRectMake(100.0f, 10.0f, 200.0f, 20.0f)];
} else {
NSLog(@"Even Cell");
[titleLabel setFrame:CGRectMake(20.0f, 10.0f, 200.0f, 20.0f)];
}
titleLabel is a label on the cell through IB and having the tag:1

No comments:

Post a Comment