美文网首页
指定UIView的某几个角为圆角

指定UIView的某几个角为圆角

作者: test_java | 来源:发表于2016-09-18 09:42 被阅读0次
    UIView *view2 = [[UIView alloc] initWithFrame:CGRectMake(30, 65,self.view.bounds.size.width-60, 300)];
    view2.backgroundColor = [UIColor redColor];
    [self.view addSubview:view2];
    
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:view2.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(6, 6)];
    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
    maskLayer.frame = view2.bounds;
    maskLayer.path = maskPath.CGPath;
    view2.layer.mask = maskLayer;
    
    显示效果

    相关文章

      网友评论

          本文标题:指定UIView的某几个角为圆角

          本文链接:https://www.haomeiwen.com/subject/vfwwettx.html