给UIView加上圆角以后 Mansory布局失效

重写- (void)layoutSublayersOfLayer:(CALayer *)layer方法

- (void)layoutSublayersOfLayer:(CALayer *)layer
{
   // 调用父类方法不能掉
    [super layoutSublayersOfLayer:layer];
    //设置所需的圆角位置以及大小
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.vertSlider.bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight | UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(50.0, 50.0)];
    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
    maskLayer.frame = self.vertSlider.bounds;
    maskLayer.path = maskPath.CGPath;
    self.vertSlider.layer.mask = maskLayer;
}

你可能感兴趣的:(给UIView加上圆角以后 Mansory布局失效)