[英]How to add a subview with drag in animation from top of the view, in iOS?
I need to add a UIDatePicker
subview on a button click to my main view. 我需要在按钮上添加一个
UIDatePicker
子视图,点击我的主视图。 How can I add the view with animation such that the subview flips in from the top of the main view and on removing ,undergoes the reverse animation ? 如何使用动画添加视图,以便子视图从主视图顶部翻转并在删除时经历反向动画? I know the subview can be added in a frame that is outside the visible area of the view and then moving it to visible area using
CABasicAnimation
will be abetter choice. 我知道子视图可以添加到视图可见区域之外的框架中,然后使用
CABasicAnimation
将其移动到可见区域将是更好的选择。 So need help regarding the animation block that I should use. 所以需要关于我应该使用的动画块的帮助。
Thanks in advance 提前致谢
Try this bellow code... here if yourView default frame with origin y = -500 then try bellow code on any UIButton
click event.. also set frame which you want 试试这个下面的代码...这里如果你的查看默认框架的原点y = -500然后在任何
UIButton
点击事件上尝试波纹管代码..也设置你想要的框架
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.75];
[UIView setAnimationDelegate:self];
CGRect frame = yourView.frame;
frame.origin.y = frame.origin.y + 500; // give any value for display yourView
yourView.frame = frame;
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:yourView cache:YES];
[UIView commitAnimations];
使用CATransaction
进行动画制作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.