gpt4 book ai didi

iphone - iOS:是否可以使用动画附加 MFMailComposeViewController?

转载 作者:可可西里 更新时间:2023-11-01 04:44:17 28 4
gpt4 key购买 nike

我正在将图像附加到 MFMailComposeViewController 中,一切正常,但我想知道是否可以提供附件动画?

例如:- 当我们从 iPhone 设备的照片库中附加图像时。并在 MailComposeViewcontroller 中选择所有选定图像移动的邮件按钮,并带有漂亮的 ANIMATION

所以请任何伙伴指导我这个东西是否可行。?如果是,那么我如何设置附件动画。

最佳答案

存在一些半解决方案。实际上,您可以添加任何 UIView 作为主应用程序窗口的 subview 。它会位于所有应用程序内容之上。使用它,您可以模拟将图像附加到 MailComposeViewcontroller

的动画

请参阅我的示例代码。此代码将 ImageView 从屏幕顶部滑动到邮件编辑器,因此它模仿添加图像作为附件。一切都有评论。

//  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];
}];

}];

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

关于iphone - iOS:是否可以使用动画附加 MFMailComposeViewController?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17321255/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com