UIView *view = [[UIView alloc]initWithFrame:CGRectMake(50, 100, 100, 100)];
    view.backgroundColor = [UIColor lightGrayColor];
    
    // 这里指出要设置哪些角为圆角
    UIRectCorner corner = (UIRectCornerTopLeft|UIRectCornerBottomLeft);
    UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:corner cornerRadii:CGSizeMake(10, 10)];
    CAShapeLayer *maskLayer = [CAShapeLayer layer];
    maskLayer.path = path.CGPath;
    // 使用maskView来完成
    view.layer.mask = maskLayer;
    
    [self.view addSubview:view];

 效果如下图:

 

posted on 2017-08-14 15:54  fatal-奚山遇白  阅读(261)  评论(0编辑  收藏  举报