Fit image of random size into a UIWebview (IOS)

后端 未结 4 671
名媛妹妹
名媛妹妹 2020-12-10 08:26

\"\"

I want to fit large image into UIwebview with keeping image ratio same as image view.

How can i do

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-10 08:49

    Set your WebView page to scale fit:

    [webView setScalesPageToFit:YES];
    

    EDIT:

    Here check these two lines also

    CGFloat screenWidth = self.view.frame.size.width;
    CGFloat screenHeight = self.view.frame.size.height;
    

    If you know what size you want them pass static values here, will fix your problem.

    e.g.

    CGFloat screenWidth = 300;
    CGFloat screenHeight = 300;
    

提交回复
热议问题