ios 入屏广告
2019-05-28 本文已影响0人
若风_412d
主界面上蒙版广告。
//背景
_retuAnimview = [[ReturnAnimationView alloc]initWithFrame:[UIApplication sharedApplication].keyWindow.bounds] ;
广告结束移除蒙版
圆环进度条

原理:
//贝塞尔曲线
@property (nonatomic, strong) UIBezierPath *bezierPath;
//layer
@property (nonatomic, strong) CAShapeLayer *progressLayer;
- (UIBezierPath *)bezierPath
{
if (!_bezierPath) {
CGFloat width = CGRectGetWidth(self.frame)/2.0f;
CGFloat height = CGRectGetHeight(self.frame)/2.0f;
CGPoint centerPoint = CGPointMake(width, height);
float radius = CGRectGetWidth(self.frame)/2;
//贝塞尔画出路径
_bezierPath = [UIBezierPath bezierPathWithArcCenter:centerPoint
radius:radius
startAngle:degreesToRadians(-90)
endAngle:degreesToRadians(270)
clockwise:YES];
}
return _bezierPath;
}
- (CAShapeLayer *)progressLayer
{
if (!_progressLayer) {
_progressLayer = [CAShapeLayer layer];
_progressLayer.frame = self.bounds;
_progressLayer.fillColor = [UIColor clearColor].CGColor;
_progressLayer.lineWidth = self.lineWidth ? self.lineWidth : 2.f;
_progressLayer.lineCap = kCALineCapRound;
_progressLayer.strokeColor = self.progressColor.CGColor ? self.progressColor.CGColor : [UIColor grayColor].CGColor;
_progressLayer.strokeStart = 0.f;
//动画
CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
pathAnimation.duration = self.animationDuration;
pathAnimation.fromValue = @(0.0);
pathAnimation.toValue = @(1.0);
pathAnimation.removedOnCompletion = YES;
pathAnimation.delegate = self;
[_progressLayer addAnimation:pathAnimation forKey:nil];
//layer的路径等于贝塞尔的路径
_progressLayer.path = _bezierPath.CGPath;
}
return _progressLayer;
}