Search code examples
uitableviewcalayerios7xcode5

Xcode 5 - iOS7 UITableView changes


since the iOS7 will be released in an about a week, I am making some changes on the current version of my app. I have noticed that UITableViews hadn't changed a lot, but there is one think that i can't understand.

I am using grouped UITableViews, which look on the screen like the plain ones but only of course separated, without round corners. Since I have seen that apple has changed the corners of the grouped tableview in the iOS7 Settings, how can i do that?

I have tried with layer shapes bezier paths, but none of these worked. Any advice how can i make those corners round?


Solution

  • You can try doing something like this:

    #define inset 20.0f
    
    - (void)setFrame:(CGRect)frame
    {
        // To bring about the rounded corner radius in iOS7
        if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0"))
        {
            frame.origin.x += inset;
            frame.size.width -= 2 * inset;
            [super setFrame:frame];
    
            super.layer.cornerRadius = 5.0f;
            [super setClipsToBounds:YES];
        }
    }
    

    Put this inside your custom UITableViewCell class.