ios - 如何在不使用pushviewcontroller的情况下制作 "pushviewcontroller"动画?

标签 ios animation uiview navigationcontroller pushviewcontroller

我想做像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/

相关文章:

iphone - 与 UIToolbar 共享功能娱乐

iphone - 模糊 UILabel 作为 UITableViewCell contentView 的编程 subview

google-chrome - CSS3 兼容性问题

ios - QuickBlox 聊天 : can't perform video call

ios - iOS 核心数据瞬变如何工作?

ios - 我正在使用 UUID 从 iOS 设备获取唯一代码,但在卸载或删除并重新安装时 id 已更改

javascript - Select2.js 和 jQuery slideDown 动画滞后/抖动

CSS 关键帧动画隐藏在 Firefox 开始之前,但不在 Internet Explorer 中

iphone - 将 UIScrollView 与 UIView subview 连接起来

ios - 将项目集成到单个项目中