gpt4 book ai didi

iphone - 使用自定义动画删除自定义 UIStoryboardSegue

转载 作者:行者123 更新时间:2023-11-28 22:46:35 27 4
gpt4 key购买 nike

我看过几个示例如何使用自定义动画呈现自定义 UIStoryboardSegue。基本上,您将 UIStoryBoardSegue 子类化并覆盖“perform”方法,即像这样:

- (void)perform
{
UIViewController *source = self.sourceViewController;
UIViewController *destination = self.destinationViewController;

// Create a UIImage with the contents of the destination
UIGraphicsBeginImageContext(destination.view.bounds.size);
[destination.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *destinationImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

// Add this image as a subview to the tab bar controller
UIImageView *destinationImageView = [[UIImageView alloc] initWithImage:destinationImage];
[source.parentViewController.view addSubview:destinationImageView];

// Scale the image down and rotate it 180 degrees (upside down)
CGAffineTransform scaleTransform = CGAffineTransformMakeScale(0.1, 0.1);
CGAffineTransform rotateTransform = CGAffineTransformMakeRotation(M_PI);
destinationImageView.transform = CGAffineTransformConcat(scaleTransform, rotateTransform);

// Move the image outside the visible area
CGPoint oldCenter = destinationImageView.center;
CGPoint newCenter = CGPointMake(oldCenter.x - destinationImageView.bounds.size.width, oldCenter.y);
destinationImageView.center = newCenter;

// Start the animation
[UIView animateWithDuration:0.5f
delay:0
options:UIViewAnimationOptionCurveEaseOut
animations:^(void) {
destinationImageView.transform = CGAffineTransformIdentity;
destinationImageView.center = oldCenter;
}
completion: ^(BOOL done) {
// Remove the image as we no longer need it
[destinationImageView removeFromSuperview];

// Properly present the new screen
[source presentViewController:destination animated:NO completion:nil];
}];
}

但是如果我想在从屏幕上移除 Segue 时自定义动画,我该怎么办?覆盖此类中的其他一些方法并调用它。或者在我调用“dismissViewController”的地方做动画,感觉不合逻辑?

如有答复,将不胜感激

艺术

最佳答案

要更改 dismissViewController 上的动画,您必须将 modalTransitionStyle 设置为 presentedViewController 上的 UIModalTransitionStyle .

- (IBAction)dismiss:(id)sender {
self.presentingViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
}

关于iphone - 使用自定义动画删除自定义 UIStoryboardSegue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13083184/

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