Cat Learn iOS TableView the way to enlarge pictures

Source: Internet
Author: User

Cat Share, must boutique

Original articles, welcome reprint. Reprint Please specify: Sanayu's Blog
Address: http://blog.csdn.net/u013357243

One: Effect

TableView drop down when the upper part of the picture put on the assembly

Two: Code

Go directly to the code and do your own research.

#import "NYViewController.h" //height of the pictureConst CGFloatNYTOPVIEWH = -; @interface nyviewcontroller ()@property(nonatomic,Weak)Uiimageview*topview;@end @implementation nyviewcontroller - (void) viewdidload{[SuperViewdidload];//Set inner margin (let cell move down a distance)     Self. TableView. Contentinset= Uiedgeinsetsmake (NYTOPVIEWH *0.5,0,0,0);Uiimageview*topview = [[UiimageviewALLOC] init]; TopView. Image= [UIImageimagenamed:@"Biaoqingdi"]; TopView. Frame= CGRectMake (0,-NYTOPVIEWH, the, NYTOPVIEWH);//Set the picture content mode to scale by the original aspect ratioTopView. Contentmode= Uiviewcontentmodescaleaspectfill; [ Self. TableViewInsertsubview:topview Atindex:0]; Self. TopView= TopView;}#pragma mark-Data source methods- (Nsinteger) TableView: (UITableView*) TableView numberofrowsinsection: (Nsinteger) section{return  -;} - (UITableViewCell*) TableView: (UITableView*) TableView Cellforrowatindexpath: (Nsindexpath*) indexpath{Static NSString*id = @"Cell";UITableViewCell*cell = [TableView dequeuereusablecellwithidentifier:id];if(!cell) {cell = [[UITableViewCellAlloc] Initwithstyle:uitableviewcellstylesubtitle Reuseidentifier:id]; } cell. Textlabel. Text= [NSStringstringwithformat:@"test Data---%d", Indexpath. Row];returnCell;} - (void) Scrollviewdidscroll: (Uiscrollview*) scrollview{//How many distances are dragged down    CGFloatDown =-(NYTOPVIEWH *0.5)-ScrollView. Contentoffset. Y;if(Down <0)return;CGRectframe = Self. TopView. Frame;///5 determines the speed at which the image becomes larger , the higher the value, the fasterFrame. Size. Height= Nytopviewh + Down *5; Self. TopView. Frame= frame;}@end

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Cat Learn iOS TableView the way to enlarge pictures

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.