开发者

Trying to create a pop-up UITableView with rounded corners

开发者 https://www.devze.com 2023-04-07 16:40 出处:网络
Been racking my brains to no avail with this one - I want to have a UITableView pop up, so it\'s floating over the stuff underneath, but with rounded corners. I don\'t know whether I need to use a cli

Been racking my brains to no avail with this one - I want to have a UITableView pop up, so it's floating over the stuff underneath, but with rounded corners. I don't know whether I need to use a clipping path in a UIView's drawRect (which I can't get to do anything except show the table with square corners) or if there's something obvious I'm missing.

I want to avoid the use of a graphic with rounded corners which I place a slightly 开发者_Go百科smaller table on, though if it comes to it at least I know how to bodge it that way.

Any help / pointers much appreciated!


If I understand you correctly then this should help you:

  1. In your .m file add #import <QuartzCore/QuartzCore.h>
  2. Add dependency from QuartzCore.framework
  3. Add the below code to your viewDidLoad method:

Code:

tableView.layer.borderColor = [[UIColor darkGrayColor] CGColor];
tableView.layer.borderWidth = 1.0;
tableView.layer.cornerRadius = 10.0;
0

精彩评论

暂无评论...
验证码 换一张
取 消