给某视图添加部分圆角

2016-10-02  本文已影响22人  Heikki_
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];
上一篇 下一篇

猜你喜欢

热点阅读