Getting a border around a UITableView, like a UIActionSheet
The UIActionSheet, when it has lots of items, is presented as a table with a border around it.
I'm trying to get a similar effect because I have a UIView with multiple UITableViews and I'd like to visually separate them. I'd like to use a border graphic that I specify.
Notice that with the UIActionSheet, the table actually sits inside the border and you see the table scroll underneath the rounded corners. You can see this in the Photos app if you view an image in landscape mode and hit the bottom-left hand corner button.
How do I get this same effect?
Edit: the "On This Day" by Sophiestication Software does something similar to w开发者_运维技巧hat I want. The app uses a custom graphic that sits on top of a scrolling view so that the scrolling content appears to be underneath the image.
The simplest way is probably to add a border on the CALayer of the UITableView:
CALayer *layer = tableview.layer;
layer.borderWidth = 2;
layer.borderColor = [[UIColor redColor] CGColor];
layer.cornerRadius = 10;
layer.masksToBounds = YES;
Note that you need to include <QuartzCore/QuartzCore.h>
and link with the QuartzCore framework.
layer.borderSize
did not work for me layer.borderWidth
did the trick.
精彩评论