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

2024-08-13  本文已影响0人  布呐呐u
    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;
上一篇 下一篇

猜你喜欢

热点阅读