标签:
使用UIBezierPath。下面给出一段示例代码。
1 UIView *view2 = [[UIView alloc] initWithFrame:CGRectMake(120, 10, 80, 80)]; 2 view2.backgroundColor = [UIColor redColor]; 3 [self.view addSubview:view2]; 4 5 UIBezierPath maskPath = [UIBezierPath bezierPathWithRoundedRect:view2.bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(10, 10)]; 6 CAShapeLayer maskLayer = [[CAShapeLayer alloc] init]; 7 maskLayer.frame = view2.bounds; 8 maskLayer.path = maskPath.CGPath; 9 view2.layer.mask = maskLayer; 10 11 12 //指定了需要成为圆角的角。该参数是UIRectCorner类型的,可选的值有: 13 14 * UIRectCornerTopLeft 15 * UIRectCornerTopRight 16 * UIRectCornerBottomLeft 17 * UIRectCornerBottomRight 18 * UIRectCornerAllCorners
标签:
原文地址:http://www.cnblogs.com/helmsyy/p/5430686.html