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