存在一些半解决方案。实际上,您可以添加任何UIView
作为主应用程序窗口的子视图。它将位于所有应用程序内容之上。使用它,您可以模拟将图像附加到的动画MailComposeViewcontroller
请参阅我的示例代码。此代码将图像视图从屏幕顶部滑动到邮件编辑器,因此它模仿将图像添加为附件。一切都被评论了。
// Get apps main window
UIWindow *window = [[UIApplication sharedApplication] keyWindow];
// Setup frames of animated image view in apps window - adjust to your needs
CGRect finalImageFrame = CGRectMake(30, 220, window.frame.size.width-60, 100);
CGRect initialImageFrame = finalImageFrame;
initialImageFrame.origin.y = -initialImageFrame.size.height;
// Create image view to be animated as attachment
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"myImage"]];
imageView.frame = initialImageFrame;
imageView.backgroundColor = [UIColor redColor];
// Add animated image view to window
[window addSubview:imageView];
// Animate image view with slide in from top
[UIView animateWithDuration:0.4
animations:^{
imageView.frame = finalImageFrame;
}];
// Present mail composer
[self presentViewController:mailComposer animated:YES completion:^{
// Once the controller appears, hide the image view - adjust this animation according to you needs
[UIView animateWithDuration:0.4
animations:^{
imageView.alpha = 0;
} completion:^(BOOL finished) {
[imageView removeFromSuperview];
}];
}];
当然代码可能需要一些调整和润色,但它显示了概念。您可以使用动画来制作更好的效果。我会添加很多动画调整,但我想让示例代码尽可能短;-)