开发者

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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜