只在左边和右边加圆角

设置控件圆角,只设置上面两个角的圆角(任意角)

http://blog.csdn.net/shuilanjuedemaomn/article/details/45644529

代码(通过贝塞尔曲线重绘layer层)

    1. UIImageView *picImageView = [[UIImageView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];  
    2.     picImageView.backgroundColor = [UIColor greenColor];  
    3.     [self.view addSubview:picImageView];  
    4.       
    5.     UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:picImageView.bounds byRoundingCorners:UIRectCornerTopLeft|UIRectCornerTopRight cornerRadii:CGSizeMake(10, 10)]; // UIRectCornerBottomRight通过这个设置  
    6.       
    7.     CAShapeLayer *maskLayer = [CAShapeLayer layer];  
    8.     maskLayer.frame = picImageView.bounds;  
    9.     maskLayer.path = maskPath.CGPath;  
    10.       
    11.     picImageView.layer.mask = maskLayer; 
原文地址:https://www.cnblogs.com/tufei7/p/7843799.html