我想做像NavigationController PushViewController的动画那样的动画。 但我没有 NavigationController,我不想制作它。
所以我想问是否可以在UIViewController中做它的动画?谢谢!
<小时/>哦忘了说,我正在尝试单击按钮后切换 View 。 现在使用presentModalViewController,但我不喜欢它的动画..
最佳答案
您可以为 subview 的 origin
属性设置动画,使其在将其添加到主视图后沿 x 轴减小。
编辑:
使用这样的东西:
// retrieve the screen bounds
CGRect sBounds = [[UIScreen mainScreen] bounds];
// the origin point is just on the right of the screen
CGRect newFrame = CGRectMake(sBounds.size.width,
0.0,
sBounds.size.width,
sBounds.size.height);
// set your view frame
[mySecondView setFrame:newFrame];
// add it to the main view
[mainView addSubview:mySecondView];
// then animate your view
[UIView animateWithDuration:0.5 // set the interval you want
animations:^{
mySecondView.frame.origin = sBounds.origin;
}
];
关于ios - 如何在不使用pushviewcontroller的情况下制作 "pushviewcontroller"动画?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6650907/