Problem with rounded corner in UITableView in Objective C

44 views Asked by At

Here is my problem. I have embed inside a UIVIew a UITableView with 3 rows. The UITableView should show a drop-shadow and should have rounded corners. To do this I created the method "setShadowsForViews" which I call in ViewDidLoad.

- (void) setShadowsForViews: (UIView *)view{
    view.backgroundColor = COLOR_WHITE;
    view.layer.cornerRadius = 8.0;
    view.layer.shadowColor = UIColor.blackColor.CGColor;
    view.layer.shadowOpacity = 0.4;
    view.layer.shadowRadius = 5;
    view.layer.shadowOffset = CGSizeMake(5, 5);
}

Also inside ViewDidLoad, I've inserted this piece of code:

self.tableView.clipsToBounds = NO;
self.tableView.layer.masksToBounds = NO;

So, now the shadow is visible outside the TableView.

The problem is that by doing this, the corners are not rounded, but the TableView takes the shape of the underlying content (with sharp corners). How can I fix this?

Here is a screenshot:

enter image description here

0

There are 0 answers