5

I am working on attach images into MFMailComposeViewController everything is fine working but i want to know that is it Possible to give animation of Attachment?

For Ex:- When we attach images from Photo Gallery in iPhone Device. and while select mail Button that all selected Images Move's in MailComposeViewcontroller with Nice ANIMATION.

So please can any-buddy guide me this stuff is possible or not.? and if YES then how can i set Animation of Attachment.

4

2 回答 2

2

存在一些半解决方案。实际上,您可以添加任何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];
                     }];

}];

当然代码可能需要一些调整和润色,但它显示了概念。您可以使用动画来制作更好的效果。我会添加很多动画调整,但我想让示例代码尽可能短;-)

于 2013-06-26T13:58:47.327 回答
1

那是 iOS 自定义动画效果,不会作为 iOS API 公开,所以不,你不能开箱即用地获得这种效果。我知道这种效果不会暴露给开发人员的原因是来自Apple iOS 6 Docs。只有一种方法可以处理,animate并且是标准的一种。

你可以尝试的是这个。在用户从他的照片库(即来自ALAssetsLibrary)中选择图像后,您可以为看起来像MFMailComposeViewController. 动画将类似于 iOS 提供的动画,即背景褪色、MFMailComposeViewController出现以及位于邮件“正文”部分的图像。动画完成后,删除“图像”并显示使用选项调用MFMailComposeViewController的实际调用。希望我很清楚。本质上,您提供的是一种幻觉,一旦动画完成,就消除了幻觉并展示了现实。MFMailComposeViewControlleranimaiton:FALSEMFMailComposeViewController

理论上这可以工作,但必须测试确切的动画时间和用户感知的感觉。

于 2013-06-26T13:35:43.440 回答