美文网首页
下拉放大

下拉放大

作者: 光_遥远 | 来源:发表于2016-08-08 09:04 被阅读0次

@interfaceViewController()

//属性

@property(nonatomic,strong)UITableView*tableView;

@property(nonatomic,strong)UIView*vie;

@property(nonatomic,strong)UIImageView*imagV;

@end

@implementationViewController

- (void)viewDidLoad {

[superviewDidLoad];

self.view.backgroundColor=[UIColorblueColor];

//代理方法

self.tableView=[[UITableViewalloc]initWithFrame:self.view.framestyle:UITableViewStylePlain];

_tableView.delegate=self;

_tableView.dataSource=self;

_vie.contentMode=UIViewContentModeScaleAspectFill;

_vie.layer.masksToBounds=YES;

[_tableViewregisterClass:[UITableViewCellclass]forCellReuseIdentifier:@"cell"];

[self.viewaddSubview:self.tableView];

}

-(NSInteger)numberOfSectionsInTableView:(UITableView*)tableView

{

return1;

}

-(UIView*)tableView:(UITableView*)tableView viewForHeaderInSection:(NSInteger)section

{

self.vie=[[UIViewalloc]initWithFrame:CGRectMake(0,0,self.view.frame.size.width,200)];

self.imagV=[[UIImageViewalloc]initWithFrame:_vie.frame];

_imagV.image=[UIImageimageNamed:@"1.png"];

[self.vieaddSubview:_imagV];

return_vie;

}

- (CGFloat)tableView:(UITableView*)tableView heightForHeaderInSection:(NSInteger)section

{

return200;

}

-(void)scrollViewDidScroll:(UIScrollView*)scrollView

{

if(_tableView.contentOffset.y<0) {

self.imagV.frame=CGRectMake(0,_tableView.contentOffset.y,self.view.frame.size.width,200-_tableView.contentOffset.y);

}

}

-(NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section

{

return200;

}

-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath

{

UITableViewCell*cell=[tableViewdequeueReusableCellWithIdentifier:@"cell"forIndexPath:indexPath];

returncell;

}

相关文章

网友评论

      本文标题:下拉放大

      本文链接:https://www.haomeiwen.com/subject/vnzlsttx.html