For example, in TableView's head set a picture, pull down tableview, the above picture will show the effect of magnification.
First define the Uiimageview, set the relevant parameters
Static . F;
Expandzoomimageview = [[Uiimageview alloc] Initwithframe:cgrectmake (0,-= [UIImage imagenamed:@ "laracroft.png"= Uiviewcontentmodescaleaspectfill;
Self. TableView. Contentinset = Uiedgeinsetsmake(kimageoriginhight, 0, 0, 0 );
[self. TableView addsubview: Expandzoomimageview];
After setting up the TableView agent, add the enlarged action on the agent of scroll
-(void) Scrollviewdidscroll: (Uiscrollview *) scrollview{ cgfloat yoffset = Scrollview.contentoffset.y; if (Yoffset <-kimageoriginhight) { = self.expandZoomImageView.frame; = Yoffset; = -yoffset; = f; }}
This will make the picture have a magnified effect when the TableView is pulled down.
Among them, ImageView Contentmode in the default case is Uiviewcontentmodescaletofill, will cause the picture deformation , all related variables such as long, wide need to set their own;
Uiviewcontentmodescaleaspectfit will ensure that the picture scale is not changed, but is filled with the entire ImageView, may only part of the picture display; Uiviewcontentmodescaleaspectfill guarantee that the picture scale is the same, but it fills the entire ImageView, and maybe only some of the pictures are displayed.
Reference Demo:https://github.com/lidechao/expandzoom
iOS set up a picture to enlarge the effect