码迷,mamicode.com
首页 > 移动开发 > 详细

ios:给矩形指定角圆角

时间:2015-06-09 19:15:24      阅读:134      评论:0      收藏:0      [点我收藏+]

标签:

很简单,用遮罩,代码如下:

UIBezierPath *maskPath=  [UIBezierPath bezierPathWithRoundedRect:viewRadius.bounds byRoundingCorners:UIRectCornerBottomLeft|UIRectCornerBottomRight cornerRadii:CGSizeMake(5, 5)];
  CAShapeLayer *maskLayer=[[CAShapeLayer alloc] init];
  maskLayer.frame=viewRadius.bounds;
  maskLayer.path=maskPath.CGPath;
  viewRadius.layer.mask=maskLayer;
  viewRadius.layer.masksToBounds=YES;
viewRadius 是要实现底部角要圆角的view

其中指定角如下:

typedef NS_OPTIONS(NSUInteger, UIRectCorner) {
    UIRectCornerTopLeft     = 1 << 0,
    UIRectCornerTopRight    = 1 << 1,
    UIRectCornerBottomLeft  = 1 << 2,
    UIRectCornerBottomRight = 1 << 3,
    UIRectCornerAllCorners  = ~0UL
};

 

ios:给矩形指定角圆角

标签:

原文地址:http://www.cnblogs.com/yoon/p/4564012.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!