【问题标题】:Animate button background image动画按钮背景图像
【发布时间】:2017-05-11 05:33:18
【问题描述】:

我尝试为按钮背景图像创建动画,但不知道我是否应该这样做以获得与gif 相同的结果。我需要从上到下进行背景更改。感谢您的帮助!

【问题讨论】:

  • @LeoNatan 我想在进度条中创建诸如加载动画之类的东西,但只能使用按钮背景

标签: objective-c uibutton uiviewanimation


【解决方案1】:

尝试这样做

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"];

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-10-23
    • 2016-04-28
    • 2019-05-16
    • 2011-01-08
    • 2023-04-04
    • 1970-01-01
    相关资源
    最近更新 更多