iOS set up a picture to enlarge the effect

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.