Use CALayer to change UIButton shape?
I know how to build a round UIButton by using the c开发者_如何学GoornerRadius of the CALayer of a UIButton.
col1 = [UIButton buttonWithType:UIButtonTypeCustom];
col1.layer.cornerRadius=w/2;
col1.layer.masksToBounds=YES;
Is there a way to do more interesting things about the boundary like chop off half a corner with CALayer?
Any examples?
I'm not sure what you mean by chop off half a corner, but the only other interesting thing you can really do to change the shape of a button using CALayer is setting the mask property. Be careful, though, as this is a fairly significant performance hit, plus it won't affect the touch behavior of the button at all, only the visual.
In general, you should be setting custom background images for your buttons if you want to change how they look.
精彩评论