如何随意设置View(上下左右)的圆角
2016-11-21 本文已影响429人
0诛仙0
UIView *redView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 200, 200)];
redView.center = self.view.center;
redView.backgroundColor = [UIColor redColor];
UIRectCorner rectCorner = UIRectCornerTopLeft|UIRectCornerTopRight;
UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:redView.bounds byRoundingCorners:rectCorner cornerRadii:CGSizeMake(40, 40)];
CAShapeLayer *shaperLayer = [CAShapeLayer layer];
shaperLayer.path = path.CGPath;
redView.layer.mask = shaperLayer;
[self.view addSubview:redView];
关于mask的理解,可以看之前我的一篇文章 :关于CAGradientLayer的几个小动画