主UIView包含两个子视图 - UIView_1和UIView_2 。 在UIView_2 ,有一个按钮可以显示或隐藏UIView_1 。 例如,当用户触摸按钮以显示UIView_1 , UIView_1将滑下, UIView_2将随着转换向下推 。 我对动画知之甚少。 有人可以给我看一些示例代码以供参考吗? 我应该使用CGAffineTransformMakeTranslation吗? 谢谢。
The main UIView contains two subviews - UIView_1 and UIView_2. In the UIView_2, there is a button to show or hide the UIView_1. For example, when a user touches the button to show the UIView_1, then UIView_1 will slide down and UIView_2 will push downwards with transition. I have very little knowledge in animation. Can someone show me some sample code for reference? Should I use CGAffineTransformMakeTranslation? Thanks.
最满意答案
你不需要任何如此复杂的东西。 只需更改视图的帧大小。
NSTimeInterval animationDuration = /* determine length of animation */; CGRect newFrameSize = /* determine what the frame size should be */; [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:animationDuration]; theViewToChange.frame = newFrameSize; [UIView commitAnimations];You don't need anything so complex. Just change the view's frame size.
NSTimeInterval animationDuration = /* determine length of animation */; CGRect newFrameSize = /* determine what the frame size should be */; [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:animationDuration]; theViewToChange.frame = newFrameSize; [UIView commitAnimations];更多推荐
发布评论