iOS 定义圆角控件

ios7 以前,想把UILabel变为圆角的,只需要设置layer的 cornerRadius属性,ios7以后,还需要设置 masksToBounds = true。

以下是这个属性的说明 A Boolean indicating whether sublayers are clipped to the layer’s bounds.

ios7以后不好使,大概是因为在UIlabel的layer上又绘制了新的layer,仅仅设定底层layer的cornerRadius,无法使UIlabel看起来是圆角的!

在ios8 上,button 不用设置 masksToBounds = true也可以,大概也是这个原因。

 

posted @ 2015-01-21 15:32  幻化成疯  阅读(223)  评论(0编辑  收藏  举报