ios - 向上而不是向下关闭 ViewControll

标签 ios objective-c

我正在展示一个简单的模态 ViewController 调用

[self performSegueWithIdentifier:@"SegueLogOut" sender:nil];

然而,当我关闭它时,我希望它向上移动而不是向下移动,这可能吗?

[self dismissViewControllerAnimated:YES completion:nil];

编辑:

我尝试制作自定义动画,但效果不佳。背景保持黑色,直到模态消失...

    [UIView animateWithDuration:1 animations:^{
        self.view.frame = CGRectMake(0, -self.view.frame.size.height, self.view.frame.size.width, self.view.frame.size.height);
    } completion:^(BOOL finished) {
        [self dismissViewControllerAnimated:NO completion:nil];
    } ];

最佳答案

通常,要更改 presentViewController 动画样式,您可以在 viewController 上设置一个 modalTransitionStyle 属性。

引用:https://developer.apple.com/LIBRARY/IOS/documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html#//apple_ref/occ/instp/UIViewController/modalTransitionStyle

但是,为了回答您的问题,没有一个(少数)modalTransitionStyle 具有向上动画的预定义样式。

你需要自己做动画。

关于ios - 向上而不是向下关闭 ViewControll,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20446309/

相关文章:

ios - 将 BOOL 类型的默认值设置为 YES

ios - 'custom_events' 事件需要参数 'custom_events_file' 或 'CUSTOM_APP_EVENTS'

objective-c - 没有位置服务的 iOS 后台轮询

objective-c - Subview 不会出现在 Mavericks 上;作品《山狮》

objective-c - Cocoa Touch 上不显示 UIButton 的 titleLabel.text

objective-c - 如何清除 NSDate 毫秒

iphone - 我在 cellForRowAtIndexpath 中添加了 selectRowAtIndexPath 以标记上一个选定的行但是如果滚动 tablview 它崩溃

c# - MonoGame 移动跨平台项目在 iOS 上运行良好但在 Android 上抛出错误?

ios - iOS 6 是否支持 OpenSSL?

ios - 使用 Xamarin 的文件应用程序在 iOS 上共享文件