Friday, 14 November 2014

iOS 6 Grouped Style UITableView in iOS 8 App

I came across a requirement where i have to show  iOS 6 grouped style UITableView in iOS8 App.
So i did some workaround and it really works.


  • I added a UITableView on UIViewController (Scene) in UIStoryboard.
  • I reduced the width of the UITableView and centre aligned it (eg. UIViewController width - 320px so i take 300px UITableView).
  • Add & Import QuartzCore framework.
  • In cellForRowAtIndexPath method make the cell layer corner round as per requirement and set masktobounds as shown below.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"TableCell";
    UITableViewCell *tableCell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (tableCell == nil) {
        tableCell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    tableCell.layer.cornerRadius = 5;
    tableCell.layer.masksToBounds = YES;
    [tableCell setBackgroundColor:[UIColor lightGrayColor]];

No comments:

Post a Comment