【问题标题】:Animation (may be flip animation) on button image change on tab选项卡上按钮图像更改上的动画(可能是翻转动画)
【发布时间】:2012-03-19 07:48:24
【问题描述】:

有没有办法可以在选项卡上的按钮图像更改上放置动画(可能是翻转动画)?

我知道一种方法是使用 UIView 而不是 UIButton。可以在 UIButton 上做吗?

感谢您的帮助。

【问题讨论】:

    标签: ios animation uibutton flip


    【解决方案1】:

    试试这个。它可以根据您的要求完美运行:

        [UIView transitionWithView:btn duration:0.5 options:UIViewAnimationOptionTransitionFlipFromRight animations:^{
        [btn setImage:[UIImage imageNamed:@"selectedicon.png"] forState:UIControlStateNormal];
    
        }   completion:nil];
    

    【讨论】:

      【解决方案2】:

      老问题,但这是我做类似事情的方式。它不是翻转而是淡入淡出,这对我来说效果很好,因为我的按钮没有背景(如果是这样,你会看到背景图像淡出然后又回来,看起来很奇怪;嘿,现在的趋势是无背景按钮 ;-) )...

      无论如何,这就是我所做的:

          [UIView animateWithDuration:.2f animations:^{
              _accessoryButton.alpha = 0.f;
          } completion:^(BOOL finished) {
              [_accessoryButton setImage:newIcon forState:UIControlStateNormal];
                  [UIView animateWithDuration:.2f animations:^{
                      _accessoryButton.alpha = 1.f;
              }];
          }];
      

      所以我要让按钮完全透明,更改图标,然后再次淡入按钮...

      我以为我可以为 _accessoryButton.imageView 的不透明度设置动画,但由于某种原因这不起作用

      【讨论】:

        【解决方案3】:

        检查这个问题的第一个答案,可能就是你要找的 Animating UIButton background image

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2017-01-15
          • 2013-12-21
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2014-12-22
          • 1970-01-01
          相关资源
          最近更新 更多