我正在研究UIView
。按钮单击时,此视图将展开和折叠。它的工作在 iOS< = 5 但不能正常工作 iOS6 。你可以请更正我的代码或解释它。
感谢。
我的代码:
CGFloat x= 60,y = 391,w1=210,h1=48;
[ViewShare setHidden:YES];
[UIView beginAnimations:@"animationOff" context:NULL];
[UIView setAnimationDuration:0.2f];
[ViewShare setFrame:CGRectMake(x, y, w1, h1)];
[UIView commitAnimations];
谢谢..
答案 0 :(得分:1)
Mani,你应该使用基于块的动画,因为在iOS 4.0之后不鼓励使用提交动画。
如果你尝试跨越很多IOS,并且尝试使用“弃用”方法,那么有很多GUI bug代码。顺便说一句,你的代码是正确的。
如果您在4.0之前不使用IOS,请改用
animateWithDuration:animations:completion:
以下是一个例子:
[UIView animateWithDuration: 0.2f
animations:^{
[ViewShare setFrame:CGRectMake(60, 391, 210, 48)];
}
completion:^(BOOL finished){
// what you want when the animation is done
}];
请注意,有时候,您需要根据iOS版本切换行为,它总是与GUI相关。这让我非常紧张。 :)