iOS UIBezierPath曲线绘制圆角

2018-04-24  本文已影响19人  蚂蚁也疯狂
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(20, 100, 100, 100)];
    [self.view addSubview:view];
    view.backgroundColor = [UIColor greenColor];
    
    UIBezierPath * maskPath = [UIBezierPath bezierPathWithRoundedRect:view.layer.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(10.0f, 10.0f)];
    CAShapeLayer * maskLayer = [CAShapeLayer new];
    maskLayer.frame = view.layer.bounds;
    maskLayer.path = maskPath.CGPath;
    view.layer.mask = maskLayer;
上一篇下一篇

猜你喜欢

热点阅读