天天看點

iOS 給View 設定指定位置圓角

iOS 給View 設定指定位置圓角

`

  • (instancetype)initWithFrame:(CGRect)frame

    {

    if (self = [super initWithFrame:frame]) {

    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(20, 20)];
      CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
      maskLayer.frame = self.bounds;
      maskLayer.path = maskPath.CGPath;
      self.layer.mask = maskLayer;
      
      [self createUI];
               

    }

    return self;

}

`

繼續閱讀