最近在做人臉識(shí)別庄敛,相機(jī)界面需要中間一個(gè)圓為透明倦春,圓外部分半透明拘鞋,用貝塞爾曲線實(shí)現(xiàn)如下:
//畫周圍白色半透明區(qū)域
CAShapeLayer *pShapeLayer = [CAShapeLayer layer];
pShapeLayer.fillColor = [UIColor colorWithWhite:1 alpha:0.6].CGColor;
pShapeLayer.frame = overView.frame;
[overView.layer addSublayer:pShapeLayer];
//圓弧
UIBezierPath *pPath = [UIBezierPath bezierPathWithArcCenter:CGPointMake(HALFABOUTUISCREEN_WIDTH, HALFABOUTUISCREEN_HIGHT - kCircleCenterY)
radius:self.bounds.size.width / 2.0 + self.progressStrokeWidth / 2.0 startAngle:0.0 endAngle:M_PI * 2 clockwise:YES];
pShapeLayer.path = pPath.CGPath;
//矩形
UIBezierPath *pOtherPath = [UIBezierPath bezierPathWithRect:
CGRectMake(0, 0, ScreenWidth, ScreenHeight)];
pShapeLayer.path = pOtherPath.CGPath;
[pOtherPath appendPath:pPath];
pShapeLayer.path = pOtherPath.CGPath;
//重點(diǎn)
pShapeLayer.fillRule = kCAFillRuleEvenOdd;
IMG_1449.PNG