Search code examples
iosxcode5uitableviewcornerradiusuicontainerview

How can i round corners of container table view?


I have a main view controller. It contains a table view controller ( in a container ) , i want to round out the tableview so it shows similarly to the facebook login one.

Code i have used in the child view controller ( which is a tableview controller ) in viewDidLoad :

self.tableView.layer.cornerRadius = 10.0f;
self.tableView.layer.masksToBounds = YES;
self.tableView.clipsToBounds = YES;
self.tableView.backgroundColor = [UIColor clearColor];

Result :

As you can see , when the field is selected , the corners SEEM rounded , but the white space remains. How can i make them rounded even when it isn't selected ?

Using : XCODE 5 , IOS 7


Solution

  • As you requested me to do, here is the code you wanted:

    for (CALayer *subLayer in self.tableView.layer.sublayers)
    {
        subLayer.cornerRadius = 10;
        subLayer.masksToBounds = YES;
    }