IOS 车票切半圆(贝塞尔曲线切半圆),加阴影

_ticketView.layer.backgroundColor = kColorWhite.CGColor;

    _ticketView.layer.cornerRadius = 8.0;

    _backShadow.layer.shadowColor = [UIColor colorWithRed:46/255.0 green:106/255.0 blue:229/255.0 alpha:0.1].CGColor;

    _backShadow.layer.shadowOffset = CGSizeMake(0,2);

    _backShadow.layer.shadowOpacity = 1;

    _backShadow.layer.shadowRadius = 8;

    //两个半圆

    UIBezierPath *path = [UIBezierPath bezierPathWithRect:CGRectMake(0, 0, kScreenWidth-40, 325)];

    [pathappendPath:[UIBezierPath bezierPathWithArcCenter:CGPointMake(0, 110) radius:25 startAngle:M_PI_2 endAngle:M_PI*3.0/2.0 clockwise:NO]];

    [pathappendPath:[UIBezierPath bezierPathWithArcCenter:CGPointMake(kScreenWidth-40, 110) radius:25 startAngle:M_PI*3.0/2.0 endAngle:M_PI_2 clockwise:NO]];

    CAShapeLayer *shape = [CAShapeLayer layer];

//    shape.backgroundColor = kColorClear.CGColor;

    shape.path= path.CGPath;

    _ticketView.layer.mask= shape;

    UIBezierPath *leftPath = [UIBezierPath bezierPathWithArcCenter:CGPointMake(0, 110) radius:25 startAngle:M_PI_2 endAngle:M_PI*3.0/2.0 clockwise:NO];

    UIBezierPath *rightPath = [UIBezierPath bezierPathWithArcCenter:CGPointMake(kScreenWidth-40, 110) radius:25 startAngle:M_PI*3.0/2.0 endAngle:M_PI_2 clockwise:NO];

    UIBezierPath *shadowPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, kScreenWidth-40, 325) byRoundingCorners:UIRectCornerAllCorners cornerRadii:CGSizeMake(8.0, 8.0)];

    [shadowPathappendPath:leftPath];

    [shadowPathappendPath:rightPath];

    _backShadow.layer.shadowPath = shadowPath.CGPath;


debug view hierarchy

你可能感兴趣的:(IOS 车票切半圆(贝塞尔曲线切半圆),加阴影)