【问题标题】:UIView subview not animatingUIView 子视图没有动画
【发布时间】:2015-03-03 09:59:28
【问题描述】:

我有一个 UIView 将其框架动画化为全屏。它有一个 UIImageView 作为大小相同的子视图,它会调整大小但仅在动画结束时,它不会平滑地为其图像设置动画。 Views Autoresize subviews 已设置为 YES; 对此有什么想法吗?

[UIView animateWithDuration:0.3
        delay:0 
        options:UIViewAnimationOptionAllowAnimatedContent          
        animations:^{
                      _View1.frame = fullScreenRect;
                    }
        completion:^(BOOL finished){;}];

【问题讨论】:

    标签: ios uiviewanimation


    【解决方案1】:
    [UIView animateWithDuration: 1.5f
                          delay: 0.0f
                        options: 0
                     animations:^{
                         self.View.frame = CGRectMake(10, 50 + height, width, height);
                     }
                     completion:^(BOOL finished) {
                     }];
    

    应该这样做

    【讨论】:

    • 这背后的原因是什么?为什么是 10、50 + 高度?
    【解决方案2】:

    在块中为它们设置动画:

    [UIView animateWithDuration:0.3
            delay:0 
            options:UIViewAnimationOptionAllowAnimatedContent          
            animations:^{
                          _View1.frame = fullScreenRect;
                           subview1.frame = fullScreenRect;
                        }
            completion:^(BOOL finished){;}];
    

    【讨论】:

      【解决方案3】:

      你必须设置_View1.clipsToBoud = YES;

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多