iOS 代码设置视图圆角

在某些视图我们可能需要做圆角处理,此处以UIImageView为例,我们一般的写法通常是

imageView.layer.mastToBounds = YES;

imageView.layer.cornerRadius = imageView.frame.size.width / 2.0;

突然想到0为假,非0为真,那么这句话其实可以这么写

imageView.layer.maskToBounds = imageView.layer.cornerRadius = imageView.frame.size.width / 2.0

记录自己开发中的小感悟

猜你喜欢

转载自blog.csdn.net/developer_zhao/article/details/82467637