ios - viewDidLoad/viewDidAppear 的 UIView 动画?

标签 ios objective-c animation uiview

我正在 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/

相关文章:

ios - MkMapView 显示蓝屏

ios - 如何将 W3C 日期 XML 转换为 NSDate iOS

IOS Objective C 祖 parent 作为委托(delegate)

objective-c - 输入附件 View 实现

c++ - QWidget - 调整大小动画

jquery - 显示 css3 动画 2 次

ios - 当我尝试在 Swift 中排序操作时,为什么总是收到此错误?

ios - iosopendev-找不到首选项框架文件错误

ios - 将包含 Latex Command for Mathematical 公式的 HTML 文本转换为输出正确公式的纯文本或属性文本

animation - 核心动画 : why can I not composite two animations?