0

我试图弄清楚如何将我的 tabbaritem 图标(图像)设置为 0,这样我就可以在它加载到屏幕上后给它一个淡入淡出动画......但我只是不知道该怎么做..

这就是我将图像添加到标签栏的方式..

- (void)viewDidAppear:(BOOL)animated
{

    self.button0.image = [UIImage imageNamed:@"icon1.png"];
    self.button1.image = [UIImage imageNamed:@"icon2.png"];
    self.button2.image = [UIImage imageNamed:@"icon3.png"];
    self.button3.image = [UIImage imageNamed:@"icon4.png"];
    self.button4.image = [UIImage imageNamed:@"icon5.png"];
    self.button5.image = [UIImage imageNamed:@"icon1.png"];


}

我将使用看起来像这样的方法为它们设置动画

[UIView animateWithDuration:0.3f
                              delay:0.0f
                            options:UIViewAnimationOptionCurveEaseOut
                         animations:^{
                             // Do your animations here
                         }
                         completion:^(BOOL finished){
                             if (finished) {
                                 // Do your method here after your animation.

                             }
                         }];

任何帮助将不胜感激。

更新这是我最新的尝试,还没有工作..

buttonImage0.image = [UIImage imageNamed:@"icon1.png"];
    buttonImage0.alpha = 0.0;
    self.button0.image = buttonImage0.image;


    [UIView animateWithDuration:0.1f
                          delay:0.0f
                        options:UIViewAnimationOptionTransitionNone
                     animations:^{
                         // Do your animations here.
                         buttonImage0.alpha = 1.0;
                     }
                     completion:^(BOOL finished){
                         if (finished) {
                             // Do your method here after your animation.
                         }
                     }];
4

1 回答 1

0

UIButton 是 UIView 的子类。UIView 有一个 alpha 属性。

尝试:

self.button0.alpha = 0.0;
self.button1.alpha = 0.0;
self.button2.alpha = 0.0;
self.button3.alpha = 0.0;
self.button4.alpha = 0.0;
self.button5.alpha = 0.0;

在你看来DidAppear;

然后使用相同的 alpha 属性将缓动函数放入 animateWithDuration 例程中!

于 2012-06-13T01:57:37.113 回答