【问题标题】:Animate embedded UIWebView frame property动画嵌入 UIWebView 框架属性
【发布时间】:2011-08-06 08:00:33
【问题描述】:

经过长时间的搜索没有结果, 也许有人知道以下问题的答案:

我有一个 UIView,其中包含一个 UIWebView 作为子视图。 UIView 只是一个包装器,因此我可以在 UIWebView 之上放置按钮等。 我现在想同时为 UIView 和 UIWebView 的调整大小和重新定位设置动画。我希望它看起来只是一个正在调整大小的 UIWebView。 我尝试了各种动画技术:块/提交、隐式/显式、 比如这样:

[UIView beginAnimations:@"zoomIn" context:nil];  
[UIView setAnimationDuration:1.0];  

myWrapperUIView.frame = CGRect(0.0, 0.0, 500.0, 500.0);  
myUIWebView.frame = CGRect(0.0, 0.0, 500.0, 500.0);

[UIView commitAnimations];

但我总是得到 UIView 的动画有点正确的结果,但是里面的 UIWebView 只是立即切换到新帧,所以如果我从更大的帧缩放,UIWebView 周围的空白空间会在动画期间缩小。

我还尝试了 UIWebView 的嵌入动画,但结果相同。

我的问题是:
有没有办法同时为两个视图设置动画,以便在每个时间点 UIWeb 都会填充 UIView?

谢谢你,
迈克尔

【问题讨论】:

  • 你解决了上面提到的问题吗???因为我也有同样的问题......请让我知道你是如何解决它的......

标签: animation uiview uiwebview frame


【解决方案1】:

使用 CGAffineTransform 并使用 transform 属性缩放视图,它会完成这项工作。

myWrapperUIView.frame = CGRect(0.0, 0.0, 500.0, 500.0);  
myUIWebView.frame = CGRect(0.0, 0.0, 500.0, 500.0);
self.window.userInteractionEnabled =NO;
myWrapperUIView.transform = CGAffineTransformMakeScale(0.01, 0.01);
myUIWebView.transform = CGAffineTransformMakeScale(0.01, 0.01);
[UIView animateWithDuration:ANIMATIONDURATION animations:^{
    myWrapperUIView.transform = CGAffineTransformMakeScale(1.0, 1.0);
    myUIWebView.transform = CGAffineTransformMakeScale(1.0, 1.0);
    }completion:^(BOOL finished) {
      self.window.userInteractionEnabled = YES;
}];

希望这有帮助,

【讨论】:

    【解决方案2】:

    您必须为您的 Web 视图设置自动调整大小掩码。

    http://developer.apple.com/library/ios/#documentation/uikit/reference/uiview_class/uiview/uiview.html

    @property(nonatomic) UIViewAutoresizing autoresizingMask

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-04
      • 2018-02-08
      • 1970-01-01
      • 1970-01-01
      • 2022-07-28
      相关资源
      最近更新 更多