Now many apps set this effect, how to achieve this effect, in fact, only need a simple two methods, then we directly on the code
First we drag a tableview in the storyboard and set the navigation, then we set the picture in TableView
I wrote a method of my own and then called it in viewdidload, or I can set it directly in the viewdidload.
Uiimageview *imageview = [[Uiimageview alloc]initwithframe:cgrectmake (00)]; [ImageView sd_setimagewithurl:[nsurl URLWithString:self.goods.image_default] placeholderimage:[uiimage imagenamed: @ "crazy"= ImageView;
Method One:
//ScrollView method views are called in real time when the view is sliding- (void) Scrollviewdidscroll: (Uiscrollview *) scrollview{cgfloat width=Self.view.frame.size.width; //Picture WidthCGFloat Yoffset =Scrollview.contentoffset.y; //the Y value of the offset if(Yoffset <0) {cgfloat Totaloffset= $+ABS (Yoffset); CGFloat F= Totaloffset/ $; //The frame of the stretched picture should be scaled in the same scale. Self.tableView.tableHeaderView.frame = CGRectMake (-(width *f-width)/2, Yoffset, Width *F, Totaloffset); }}
Method Two:
-(void) Scrollviewdidscroll: (Uiscrollview *) scrollview{//Get offsetCgpoint offset =Scrollview.contentoffset; //decide whether to change if(Offset.y <0) {CGRect rect=Self.tableView.tableHeaderView.frame; //We just need to change the Y-value and the height of the imageRECT.ORIGIN.Y =Offset.y; Rect.size.height= $-Offset.y; Self.tableView.tableHeaderView.frame=rect; }}
The effect is as follows:
Ios:tableview effect of the drop-down of the table head