美文网首页
(Objective-C) UIView指定方向设置圆角

(Objective-C) UIView指定方向设置圆角

作者: 布呐呐u | 来源:发表于2024-08-13 09:47 被阅读0次
  • 左上、右上
    UIView *testView = UIView.new;
    testView.frame = CGRectMake(0, 0, 200, 200);
    testView.center = self.center;
    [self addSubview:testView];
    
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:testView.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(10, 10)];
    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
    maskLayer.frame = testView.bounds;
    maskLayer.path = maskPath.CGPath;
    testView.layer.mask = maskLayer;

相关文章

网友评论

      本文标题:(Objective-C) UIView指定方向设置圆角

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