美文网首页
给某视图添加部分圆角

给某视图添加部分圆角

作者: Heikki_ | 来源:发表于2016-10-02 21:24 被阅读22次
UIView *view = [[UIView alloc]init];

view.frame = CGRectMake(0, 0, 100, 100);
view.center = self.view.center;
view.backgroundColor = [UIColor redColor];

CGRect rect = view.bounds;
CGSize radio = CGSizeMake(30, 30);//圆角大小
UIRectCorner corner = UIRectCornerTopLeft|UIRectCornerBottomLeft;//圆角位置
UIBezierPath * path = [UIBezierPath bezierPathWithRoundedRect:rect byRoundingCorners:corner cornerRadii:radio];
CAShapeLayer *masklayer = [[CAShapeLayer alloc]init];
masklayer.frame = view.bounds;
masklayer.path  = path.CGPath;
view.layer.mask = masklayer;


[self.view addSubview:view];

相关文章

网友评论

      本文标题:给某视图添加部分圆角

      本文链接:https://www.haomeiwen.com/subject/yjbdyttx.html