本文介绍了如何在单个UIView中淡入和淡出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

示例我尝试通过fadein将cell.accessoryView从picture1更改为picture2

examplei try to change cell.accessoryView from picture1 to picture2 by fadein

但是我的问题是我只有一个附件视图(一个UIView)

but my problem is i only have one accessoryView(one UIView)

有什么主意吗?

推荐答案

如果要淡入淡出,则必须修改附件视图,而不是重置 cell.accessoryView .最简单的方法可能是为您的附件提供两个子视图,每个子视图分别用于picture1和picture2.

If you want a fade, you'll have to modify your accessory view rather than reset cell.accessoryView. The simplest approach may be to give your accessory two subviews, one each for picture1 and picture2.

UIImageView *imageView1 = [[[UIImageView alloc] init] autorelease];
UIImageView *imageView2 = [[[UIImageView alloc] init] autorelease];
imageView2.alpha = 0;
[cell.accessoryView addSubview:imageView1];
[cell.accessoryView addSubview:imageView2];

然后执行以下操作以淡入淡出:

Then do the following to fade between:

[UIView beginAnimations:@"" context:nil];
imageView1.alpha = 0;
imageView2.alpha = 1;
[UIView commitAnimations];

这篇关于如何在单个UIView中淡入和淡出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-21 07:12