一、设置矩形视图的某个角或某几个角为圆角
UIView*view=[[UIViewalloc]initWithFrame:CGRectMake(100,100,80,30)];
view.backgroundColor=[UIColorblackColor];
[self.viewaddSubview:view];
UIBezierPath *maskPath = [UIBezierPathbezierPathWithRoundedRect:view.boundsbyRoundingCorners:UIRectCornerTopRight |UIRectCornerBottomLeft cornerRadii:CGSizeMake(view.frame.size.width/3,view.frame.size.width/3)];
CAShapeLayer *maskLayer = [[CAShapeLayeralloc] init];
maskLayer.frame = view.bounds;
maskLayer.path = maskPath.CGPath;
view.layer.mask = maskLayer;
效果: