- (UIScrollView *)bgScrollView{ if(!bgScrollView){ bgScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(self.statusView.frame), CGRectGetWidth(self.view.frame), CGRectGetHeight(self.view.frame)-20-49)]; bgScrollView.delegate=self; bgScrollView.showsVerticalScrollIndicator=NO; bgScrollView.showsHorizontalScrollIndicator=NO; bgScrollView.backgroundColor = [UIColor hx_colorWithHexRGBAString:@"#f6f6f6"]; bgScrollView.hidden=YES; bgScrollView.contentInset = UIEdgeInsetsMake(142*CGRectGetWidth(self.view.frame)/375, 0, 0, 0); } return bgScrollView; } - (UIImageView *)topImageView{ if(!topImageView){ topImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0,-(142*CGRectGetWidth(self.view.frame)/375), CGRectGetWidth(self.view.frame),142*CGRectGetWidth(self.view.frame)/375)]; topImageView.backgroundColor = [UIColor hx_colorWithHexRGBAString:@"#ffffff"]; topImageView.contentMode = UIViewContentModeScaleAspectFill; [topImageView sd_setImageWithURL:[NSURL URLWithString:@"www.baidu.com"] placeholderImage:[UIImage imageNamed:@"top_logo.png"] options:SDWebImageRetryFailed]; } return topImageView; } - (void)scrollViewDidScroll:(UIScrollView *)scrollView{ CGPoint point = scrollView.contentOffset; if (point.y < -(142*CGRectGetWidth(self.view.frame)/375)) { CGRect rect = self.topImageView.frame; rect.origin.y = point.y; rect.size.height = -point.y; self.topImageView.frame = rect; } }
1.設置scrollview圖片偏移代理
2.設置圖片frameblog
3.在滑動代理中修改圖片frame圖片