ios - 在 iOS 8 上使用自定义 UI 动画显示和关闭共享扩展

标签 ios objective-c xcode ios8 ios-app-extension

我正在为带有自定义 UI 的 iOS 8 开发共享扩展,但它显示时没有动画,我该怎么做?这是一个普通的 UIViewController。

此外,它在 iPad 上全屏显示,我希望它是一个模态视图 Controller ,出现在屏幕中央但不适合它,我该怎么做?

问候。

最佳答案

这是迄今为止我找到的最干净的解决方案,可以让我的自定义 View Controller 进出动画!

动画输入:

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

    self.view.transform = CGAffineTransformMakeTranslation(0, self.view.frame.size.height);
    [UIView animateWithDuration:0.25 animations:^
    {
        self.view.transform = CGAffineTransformIdentity;
    }];
}

关闭:

- (void)dismiss
{
    [UIView animateWithDuration:0.20 animations:^
    {
        self.view.transform = CGAffineTransformMakeTranslation(0, self.view.frame.size.height);
    } 
    completion:^(BOOL finished) 
    {
        [self.extensionContext completeRequestReturningItems:nil completionHandler:nil];
    }];
}

关于ios - 在 iOS 8 上使用自定义 UI 动画显示和关闭共享扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24786716/

相关文章:

ios - 无法在模拟器中使用 MFMailComposeViewController 发送电子邮件

ios - 如何知道 ios 中另一个 View 类中一个 View Controller 的 ImageView 的 x、y 坐标和宽度、高度?

iphone - 将数组索引传输到下一个 Controller

ios - Xcode 9 - 无法发出预编译 header

html - index.html 未按 IOS 应用程序开发中的要求运行

c# - Unity3D游戏: deal with constants within one file

iphone - 取消alertview的功能

ios - AVPlayerViewController 问题

ios - 如何使用 iPhone 通过 SSH 连接到树莓派?

c++ - 如何在 Xcode 中使用参数