重寫(xiě)- (void)layoutSublayersOfLayer:(CALayer *)layer方法
- (void)layoutSublayersOfLayer:(CALayer *)layer
{
// 調(diào)用父類(lèi)方法不能掉
[super layoutSublayersOfLayer:layer];
//設(shè)置所需的圓角位置以及大小
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;
}