麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 系統(tǒng) > iOS > 正文

iOS tableView實(shí)現(xiàn)頂部圖片拉伸效果

2019-10-21 18:41:11
字體:
供稿:網(wǎng)友

大家可能注意到一些app的tableView的頂部圖片,會(huì)隨著你拉伸而跟著拉伸變大,下面這是我的一些想法

原圖:

iOS,tableView,頂部圖片拉伸

效果圖:

iOS,tableView,頂部圖片拉伸

下面附上代碼吧,這里的圖片不是添加在tabview的header上

#define SCREEN_W [UIScreen mainScreen].bounds.size.width #define SCREEN_H [UIScreen mainScreen].bounds.size.height #define TOP 200 //頂部預(yù)留  #import "ViewController.h"  @interface ViewController ()<UITableViewDataSource,UITableViewDelegate> @property (nonatomic,strong)UITableView *tableV; @end  @implementation ViewController  - (void)viewDidLoad {  [super viewDidLoad];   [self creatTableView]; }  - (void)creatTableView {  self.automaticallyAdjustsScrollViewInsets = NO;  self.tableV = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H) style:UITableViewStylePlain];  self.tableV.contentInset = UIEdgeInsetsMake(TOP, 0, 0, 0);    self.tableV.delegate = self;  self.tableV.dataSource = self;    //創(chuàng)建頂部圖片  UIImageView * imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, -TOP, SCREEN_W, TOP)];  imageView.tag = 1000;    //更改圖片顯示模式 根據(jù)圖片原有尺寸進(jìn)行顯示 將多余部分切除  imageView.contentMode = UIViewContentModeScaleAspectFill;    //多余部分隱藏  imageView.clipsToBounds = YES;    imageView.image = [UIImage imageNamed:@"pic"];    [self.view addSubview:_tableV];  [self.tableV addSubview:imageView]; }  - (void)scrollViewDidScroll:(UIScrollView *)scrollView {  float offSet = scrollView.contentOffset.y;    if (offSet < -200)  {   UIImageView * tempImageView = (UIImageView*)[self.view viewWithTag:1000];      CGRect f = tempImageView.frame;   //保持圖片原點(diǎn)仍為屏幕左上方   f.origin.y = offSet;   //保證圖片根據(jù)滑動(dòng)高度拉伸   f.size.height = -offSet;   //給圖片重新設(shè)置坐標(biāo)   tempImageView.frame = f;  } }  - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {  return 10; }  - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {  static NSString *cell = @"cell";  UITableViewCell *myCell = [tableView dequeueReusableCellWithIdentifier:cell];  if (!myCell) {   myCell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cell];  }  myCell.textLabel.text = @"我是 cell";  return myCell; }  @end 

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持VEVB武林網(wǎng)。


注:相關(guān)教程知識(shí)閱讀請移步到IOS開發(fā)頻道。
發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 可以免费看av| 黄色网址免费进入 | 中文字幕一区久久 | 女人一级一级毛片 | 日本大片在线播放 | 久久国产精品久久久久久久久久 | 91精品国产91久久久 | 国产一国产精品一级毛片 | 久久艹精品视频 | 新久久久久久 | 国产做爰全免费的视频黑人 | 久久蜜桃香蕉精品一区二区三区 | 国产精品成人亚洲一区二区 | 欧美韩国一区 | 成年人网站国产 | 免费一级毛片免费播放 | 国产成人网 | 成人nv在线观看 | 欧美中文字幕在线视频 | 亚洲极色 | 久久最新免费视频 | 黄色特级 | 久热久操 | 久精品久久| 青草av.久久免费一区 | 孕妇体内谢精满日本电影 | 婷婷中文字幕一区二区三区 | 污片在线观看视频 | 成人福利在线视频 | 色蜜桃av| 在线成人看片 | 国内精品久久久久久2021浪潮 | 亚洲一区二区三区日本久久九 | 免费看黄色一级片 | 欧美性受xxxx人人本视频 | 免费a视频在线观看 | 在线99热 | 99爱视频 | 美女又黄又www | 国产在线一区二区三区 | 青青青在线免费 |