问题
I am trying to round the corners of a UITableViewController
or even the entire UINavigationController
using the following code:
self.view.layer.cornerRadius = 8.0f;
The problem though is that when the view is rounded off, the UINavigationBar
has a translucent, frosty background showing outside the rounded edges. I want to keep the navigation bar translucent, but I want the entire view to be rounded. With the code above, I get the following result:

How can I produce this result without the frosty background showing outside the rounded corners?
回答1:
self.view.clipsToBounds = YES;
//edit// actually, because its the nav bar there you probably want
self.navigationController.view.layer.cornerRadius = 8.0;
self.navigationController.view.clipsToBounds = YES;
///
回答2:

Add this two KeyPath in the view in which you need round corners
回答3:
self.tableView.layer.borderWidth = 0.5;
self.tableView.layer.cornerRadius = 5;
self.tableView.layer.masksToBounds = YES;
self.tableView.layer.borderColor =[[UIColor clearColor] CGColor];
self.tableView.layer.shadowColor = [[UIColor clearColor] CGColor];
self.tableView.layer.shadowOffset = CGSizeMake(0.0, 0.0);
self.tableView.layer.shadowOpacity = 0.0;
回答4:
I think you are missing this line of code :
[self.tableView.layer setMasksToBounds:YES];
[self.tableView.layer setCornerRadius:10.0];
来源:https://stackoverflow.com/questions/26251117/round-corners-of-uitableviewcontroller