webView是一個複合視圖,裏面包含有一個scrollView,scrollView裏面是一個UIWebBrowserView(負責顯示WebView的內容)web
UIView *webBrowserView = self.webView.scrollView.subviews[0];//拿到webView的webBrowserViewit
self.backHeadImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenWidth*2/3.0)];scroll
[_backHeadImageView sd_setImageWithURL:[NSURL URLWithString:self.imageUrl] placeholderImage:[UIImage imageNamed:@"placeholderImage"]];im
[self.webView insertSubview:_backHeadImageView belowSubview:self.webView.scrollView];view
//把backHeadImageView插入到webView的scrollView下面vi
CGRect frame = self.webBrowserView.frame;block
frame.origin.y = CGRectGetMaxY(_backHeadImageView.frame);placeholder
self.webBrowserView.frame = frame;
//更改webBrowserView的frame向下移backHeadImageView的高度,使其可見