开发者社区> 问答> 正文

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

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

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

展开
收起
爵霸 2016-03-19 11:25:27 3179 0
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
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载