Trying to create a pop-up UITableView with rounded corners
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:
- In your
.m
file add#import <QuartzCore/QuartzCore.h>
- Add dependency from
QuartzCore.framework
- 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;
精彩评论