如何定义一个只有上边圆角的UIButton

来源:互联网 发布:tcpudp端口号 编辑:程序博客网 时间:2024/05/01 17:55
UIView *view2 = [[UIView alloc] initWithFrame:CGRectMake(120, 10, 80, 80)];view2.backgroundColor = [UIColor redColor];[self.view addSubview:view2];UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:view2.bounds      byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight    cornerRadii:CGSizeMake(10, 10)];CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];maskLayer.frame = view2.bounds;maskLayer.path = maskPath.CGPath;view2.layer.mask = maskLayer;

byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight

参考:Rounded UIView using CALayers - only some corners - How?


0 0