我正在试图弄清楚如何将我的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.
}
}];
答案 0 :(得分: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;
在你的viewDidAppear中;
然后使用相同的alpha属性将你的缓动函数放在animateWithDuration例程中!