本文介绍了使用willTransitionToState在uitableviewcell中为textlabel设置动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我按下编辑按钮时,我试图在UItableviewcell中设置textlabel的动画。
我试图让它淡出并淡入。
淡入效果但是当我按下'编辑'时,文本标签消失了,当我按下'完成'时,我完全淡入。
I am trying to animate the textlabel in a UItableviewcell when I press the edit button.I am trying to make it fade out and fade in.fading in works but when I press 'edit' the textlabel disappears and when I press on 'done' I fades in just perfectly.
有谁可以告诉我它为什么不起作用?
Can anyone tell me why it isn't working?
提前感谢
- (void)willTransitionToState:(UITableViewCellStateMask)state {
[super willTransitionToState:state];
if ((state & UITableViewCellStateEditingMask) || (state & UITableViewCellStateShowingDeleteConfirmationMask)) {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];
label.alpha = 0.0;
[UIView commitAnimations];
}
}
- (void)didTransitionToState:(UITableViewCellStateMask)state {
[super didTransitionToState:state];
if (!(state & UITableViewCellStateEditingMask) && !(state & UITableViewCellStateShowingDeleteConfirmationMask)) {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
label.alpha = 1.0;
[UIView commitAnimations];
}
}
推荐答案
我注意到当输入willTransitionToState时动画被禁用。以下修正了它。
I noticed that when entering willTransitionToState that animations were disabled. The following fixed it.
- (void)willTransitionToState:(UITableViewCellStateMask)state
{
[super willTransitionToState:state];
//Should be enabled by default...but apparently not
[UIView setAnimationsEnabled:YES];
...
}
这篇关于使用willTransitionToState在uitableviewcell中为textlabel设置动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!