2016-12-26 140 views
-2

我尝试为按钮背景图像创建动画,但不知道我应该怎么做才能获得像这样的gif一样的结果。我需要从上到下做这个背景变化。谢谢你的帮助!动画按钮背景图片

+0

@LeoNatan我想创造这样的进度条加载动画,但只能用按钮背景 –

回答

0

尽量做到这样

CALayer *layer = [CALayer layer]; 
layer.frame = CGRectMake(0, self.view.bounds.size.height, self.view.bounds.size.width, self.view.bounds.size.height); 
layer.backgroundColor = [UIColor blueColor].CGColor; 
[self.view.layer addSublayer:layer]; 

CABasicAnimation *animation = [CABasicAnimation animation]; 
animation.keyPath = @"position.y"; 
animation.byValue = @(-self.view.bounds.size.height); 
animation.duration = 1; 

animation.fillMode = kCAFillModeForwards; 
animation.removedOnCompletion = NO; 
[layer addAnimation:animation forKey:@"Splash"];