gpt4 book ai didi

ios - viewDidLoad/viewDidAppear 的 UIView 动画?

转载 作者:塔克拉玛干 更新时间:2023-11-01 19:09:03 26 4
gpt4 key购买 nike

我正在 viewDidLoad 或 viewDidAppear 方法中尝试一个简单的 UIView 动画,但它没有动画。

UIImage *bluredScreenshot = [self.parentViewControllerScreenshot applyBlur];

[UIView transitionWithView:self.screenshotView duration:3.0f options:UIViewAnimationOptionTransitionCrossDissolve animations:^{
self.screenshotView.image = bluredScreenshot;
} completion:nil];

简单的交叉融合两个图像。当从 viewDidLoad 或 viewDidAppear 运行时,图像发生变化但不是动画。

但是假设我在按下按钮后从一个方法运行动画,它会动画。为什么?看起来很奇怪。

是否可以通过 viewDidLoad 方法实现?你会如何解决这个问题?

谢谢。

最佳答案

您需要淡入屏幕截图。如果您使用两张图片,则需要将一张图片 View 放在另一张图片之上。在调用 [super viewDidAppear:animated] 之后在 viewDidAppear: 中弹出这个;

UIImageView *imageView = [[UIImageView alloc] initWithFrame:self.screenshotView.frame];
[self.view addSubview:imageView];
[imageView setAlpha:0.0f];
imageView = blurredScreenshot;
[UIView animateWithDuration:0.3f animations:^{
[imageView setAlpha:1.0f];
} completion:^(BOOL finished){
self.imageView.image = blurredScreenshot;
[imageView removeFromSuperview];
}];

关于ios - viewDidLoad/viewDidAppear 的 UIView 动画?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19600901/

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