【发布时间】:2012-06-13 01:43:21
【问题描述】:
我正在尝试弄清楚如何将我的 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.
}
}];
【问题讨论】:
-
我不确定您是否可以设置 alpha。假设有可能,您可以在动画代码块内将 alpha 设置为 0。
-
我需要在代码块之前设置它,然后在动画中将 alpha 设置为 1(就像图像褪色一样)我想我已经弄清楚了,首先创建 imageview 并设置 alpha 和然后将该图像传递给tabbaritem,然后在代码plock中我将使图像淡入。
-
完成后我会发布代码,你们可以告诉我它有多糟糕:)
标签: iphone ios uiimageview uiimage alpha