穆斯林专业版是一款ios应用程序,根据salah计时动画太阳位置。我知道,如何动画UIImage阵列动画系列图像,但它并没有给出穆斯林专业应用程序所做的效果。我是否需要使用任何动画库,或者它可以通过iOS内置框架实现。
答案 0 :(得分:1)
从这个回答:https://stackoverflow.com/a/18018275/4912496
填充动画的更新 我可以想到并快速实现唯一的事情,它创建View,并在右边的左侧填充动画,决定不是最好的,也许你会想到最好的
- (void)viewDidLoad {
[super viewDidLoad];
_acrfillview.clipsToBounds = YES;
CAShapeLayer *shape = [CAShapeLayer layer];
UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(_acrfillview.bounds.size.width / 2, _acrfillview.bounds.size.height ) radius:(_acrfillview.bounds.size.height) startAngle:0 endAngle:(M_PI) clockwise:false];
shape.path = path.CGPath;
_acrfillview.layer.mask = shape;
}
- (IBAction)startAnimation:(id)sender
{
CGPoint arcStart = CGPointMake(_sunView.center.x , _sunView.center.y);
CGPoint arcCenter = CGPointMake(0.5 * self.view.bounds.size.width, 0.5 * self.view.bounds.size.height);
CGFloat arcRadius = self.view.bounds.size.width/2 - (_sunView.frame.origin.x + _sunView.frame.size.width/2);
CGMutablePathRef arcPath = CGPathCreateMutable();
CGPathMoveToPoint(arcPath, NULL, arcStart.x, arcStart.y);
CGPathAddArc(arcPath, NULL, arcCenter.x, arcCenter.y, arcRadius, M_PI, 0, NO);
BOOL showArc = YES;
UIView* drawArcView = nil;
if (showArc)
{
drawArcView = [[UIView alloc] initWithFrame: self.view.bounds];
CAShapeLayer* showArcLayer = [[CAShapeLayer alloc] init];
showArcLayer.frame = drawArcView.layer.bounds;
drawArcView.clipsToBounds = YES;
showArcLayer.path = arcPath;
showArcLayer.strokeColor = [[UIColor blackColor] CGColor];
showArcLayer.fillColor = nil;
showArcLayer.masksToBounds = YES;
showArcLayer.lineWidth = 3.0;
[drawArcView.layer addSublayer: showArcLayer];
[self.view insertSubview: drawArcView belowSubview: _sunView];
CAShapeLayer* animateArcLayer = [[CAShapeLayer alloc] init];
animateArcLayer.frame = CGRectMake(drawArcView.layer.frame.origin.x, drawArcView.layer.frame.origin.y, 1, 1);
animateArcLayer.path = arcPath;
animateArcLayer.anchorPoint = CGPointZero;
animateArcLayer.strokeColor = nil;
animateArcLayer.fillColor = [UIColor yellowColor].CGColor;
animateArcLayer.lineWidth = 0.0;
[_acrfillview.layer addSublayer:animateArcLayer];
CGPathRef leftStartingRectPath = CGPathCreateWithRect(CGRectMake(0,0, 0, arcRadius), 0);
CGPathRef fullViewRectPath = CGPathCreateWithRect(CGRectMake(0,0, 275, arcRadius), 0);
CABasicAnimation *leftToRightAnimation = [CABasicAnimation animationWithKeyPath:@"path"];
leftToRightAnimation.duration = 5.;
leftToRightAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
leftToRightAnimation.fromValue = (__bridge id)leftStartingRectPath;
leftToRightAnimation.toValue = (__bridge id)fullViewRectPath;
leftToRightAnimation.fillMode = kCAFillModeForwards;
leftToRightAnimation.removedOnCompletion = NO;
[animateArcLayer addAnimation:leftToRightAnimation forKey:@"animatePath"];
}
// The animation
CAKeyframeAnimation *pathAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
pathAnimation.calculationMode = kCAAnimationPaced;
pathAnimation.duration = 5.0;
pathAnimation.path = arcPath;
CGPathRelease(arcPath);
[CATransaction begin];
[_sunView.layer addAnimation:pathAnimation forKey:@"arc"];
[CATransaction commit];
}