SomaMan SomaMan - 6 months ago 17
Objective-C Question

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 smaller table on, though if it comes to it at least I know how to bodge it that way.

Any help / pointers much appreciated!

Answer

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;
Comments