In fact, this effect is essentially when you tableview down to create offset. Keep the y-coordinate point of your top picture in the drop-down screen vertex (offset), and the length of the picture changes to the original height length-(offset) to the pull-up effect.
Directly on the code:
1. First create a uiview as Headerview
_topview = [[UIViewalloc]initwithframe:cgrectmake(0, 0,mcappwidth)];
_tableview. Tableheaderview =_topview;
2. Next create a uiimageview put that picture
_topimageview = [[ uiimageview alloc" initwithframe: CGRectMake ( 0 , 0 mcappwidth 80
_topimageview. Contentmode = Uiviewcontentmodescaleaspectfill;
_topimageview. Layer. Maskstobounds = YES;
[ _topimageview sd_setimagewithurl:[ nsurl urlwithstring : nil ] placeholderimage:[ uiimage imagenamed : @ "MIAN_BG" ]];
[_topviewaddsubview:_topimageview];
3. Finally introduce the ScrollView agent method to monitor the change of frame
-(void) Scrollviewdidscroll: (uiscrollview *) ScrollView
{
if (_tableview = = ScrollView) {
CGFloat yoffset = _tableview. Contentoffset. Y;
Drop down image to enlarge
if (Yoffset < 0) {
_topview . frame = CGRectMake (0 , 0, mcappwidth , 80 * Height -yoffset);
_topimageview. frame = cgrectmake(0, Yoffset, mcappwidth, * Height -Yoffset) ;
NSLog (@ "%.2f", _topimageview. y);
}
Else {
_topview. frame = cgrectmake(0, 0, mcappwidth, * Height - Yoffset);
_topimageview. y = yoffset * 0.65;
_topimageview. height = * Height -yoffset * 0.65;
}
}
}
What I'm doing here is that the relative displacement assumes that the next two lines of code need to be peered out of the other in the _TOPIMAGEVIEW.Y = _topview.y value remains the same.
I'm here. Y is your own encapsulation method direct copy will make an error.
IOS tableview drop-down image zoom in