开发者社区 问答 正文

关于根据分辨率重新定义webView尺寸

在应用中采用storyboard。不知道怎么根据屏幕分辨率对webView进行尺寸调整。
screenshot
我希望标题在两个分辨率下尺寸相同,但是webview 的高度根据分辨率调整。

不能用自动布局,因为要在ios5以上版本用。

展开
收起
爵霸 2016-03-19 11:25:27 3364 分享 版权
1 条回答
写回答
取消 提交回答
  • 实现根据屏幕调整Webview框架,可在分配webView处使用下面方法。

    CGRect webFrame = [[UIScreen mainScreen] applicationFrame];
    webFrame.origin.y -= 20.0; // statusbar 20 px cut from y of frame
    webView = [[UIWebView alloc] initWithFrame:webFrame];
    webView.scalesPageToFit = YES;
    webView.autoresizesSubviews = YES;
    webView.autoresizingMask=(UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth);
    [webView setBackgroundColor:[UIColor clearColor]];
    2019-07-17 19:07:49
    赞同 展开评论
问答分类:
问答标签:
问答地址: