Round corners of UITableViewController

扶醉桌前 提交于 2020-01-15 12:29:27

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!