示例 我尝试通过fadein
将cell.accessoryView从picture1更改为picture2但我的问题是我只有一个accessoryView(一个UIView)
任何想法?
答案 0 :(得分:6)
如果我理解你的问题......
你可以试试像
这样的东西 //-------fade out
- (void)animateFadingOut{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationDidStopSelector:@selector(animateFadingIn)];
[UIView setAnimationDelegate:self];
//set transformation
[cell.accessoryView addSubview:NewImgeView];
cell.accessoryView.alpha = 0.0;
[UIView commitAnimations];
}
-(void)animateFadingIn{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationDelegate:self];
//set transformation
cell.accessoryView.alpha = 1.0;
[UIView commitAnimations];
}
答案 1 :(得分:5)
如果您想要淡入淡出,则必须修改附件视图,而不是重置cell.accessoryView
。最简单的方法可能是为您的附件提供两个子视图,分别为picture1和picture2。
UIImageView *imageView1 = [[[UIImageView alloc] init] autorelease];
UIImageView *imageView2 = [[[UIImageView alloc] init] autorelease];
imageView2.alpha = 0;
[cell.accessoryView addSubview:imageView1];
[cell.accessoryView addSubview:imageView2];
然后执行以下操作淡出:
[UIView beginAnimations:@"" context:nil];
imageView1.alpha = 0;
imageView2.alpha = 1;
[UIView commitAnimations];