您的位置:首页 > 产品设计 > UI/UE

UIView,UIImageView支持顶端圆角的方式

2012-12-10 14:47 537 查看
最近在项目中需要只有顶端两个为圆角,其他的地方不改变,在网上看了很多地方,拿来的代码都不能直接使用。

所以决定自己研究一下,主要参考了

https://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIBezierPath_class/Reference/Reference.html#//apple_ref/occ/clm/UIBezierPath/bezierPathWithRoundedRect:byRoundingCorners:cornerRadii:

这个方法,以及CAShapeLayer这个方法

顶端圆角的设置,可以直接使用。后面会把画图相关的操作继续研究,发出来共享。

CAShapeLayer *styleLayer = [CAShapeLayerlayer];

UIBezierPath *shadowPath = [UIBezierPathbezierPathWithRoundedRect:cardStyleView.boundsbyRoundingCorners:(UIRectCornerTopLeft|UIRectCornerTopRight) cornerRadii:CGSizeMake(8.0, 8.0)];

styleLayer.path = shadowPath.CGPath;

cardStyleView.layer.mask = styleLayer;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: