欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

 更新時(shí)間:2018年05月08日 14:50:48   作者:極客學(xué)偉  
這篇文章主要為大家詳細(xì)介紹了iOS tableview實(shí)現(xiàn)頂部拉伸效果,以及頭部拉伸效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了iOS tableview頭部拉伸效果展示的具體代碼,例如探探個(gè)人信息界面拉伸效果,下拉頭像放大

代碼:

//
// PersonController.m
// Spread
//
// Created by qiuxuewei on 16/3/21.
// Copyright © 2016年 邱學(xué)偉. All rights reserved.
//

#import "PersonController.h"

@interface PersonController ()<UITableViewDataSource, UITableViewDelegate, UIScrollViewDelegate>{

}

//屬性列表
/** 頂部圖片視圖 */
@property (nonatomic, strong) UIImageView *headerImageView;
@property (nonatomic, strong) UIView *headerBackView;
/** 個(gè)人信息界面 */
@property (nonatomic, strong) UITableView *tableView;

@end

@implementation PersonController
#pragma mark - 懶加載
-(UIView *)headerBackView{
 if (_headerBackView == nil) {
  _headerBackView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 200)];
  [_headerBackView setBackgroundColor:[UIColor lightGrayColor]];
 }
 return _headerBackView;
}
-(UIImageView *)headerImageView{
 if (_headerImageView == nil) {
  _headerImageView = [[UIImageView alloc] init];
  [_headerImageView setImage:[UIImage imageNamed:@"邱_生活.JPG"]];
  [_headerImageView setBackgroundColor:[UIColor greenColor]];
  [_headerImageView setContentMode:UIViewContentModeScaleAspectFill];
  [_headerImageView setClipsToBounds:YES];
 }
 return _headerImageView;
}
-(UITableView *)tableView{
 if (_tableView == nil) {
  _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight) style:UITableViewStyleGrouped];
  [_tableView setDataSource:self];
  [_tableView setDelegate:self];
 }
 return _tableView;
}

- (void)viewDidLoad {
 [super viewDidLoad];
 // Do any additional setup after loading the view from its nib.
 //添加子視圖
 [self addChildViews];
}
#pragma mark - 類內(nèi)方法
//添加子視圖
-(void)addChildViews{
 //添加表格
 [self.view addSubview:self.tableView];
 //添加頭像圖片
 [self addHeaderImageView];
}
//添加頭像
-(void)addHeaderImageView{
 [self.tableView setTableHeaderView:self.headerBackView];
 [self.headerImageView setFrame:self.headerBackView.bounds];
 [self.headerBackView addSubview:self.headerImageView];
}


#pragma mark - UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
 return 4;
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
 return 2;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
 return 64;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
 // 不加此句時(shí),在二級(jí)欄目點(diǎn)擊返回時(shí),此行會(huì)由選中狀態(tài)慢慢變成非選中狀態(tài)。
 // 加上此句,返回時(shí)直接就是非選中狀態(tài)。
 [tableView deselectRowAtIndexPath:indexPath animated:YES];
}

//初始化cell
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

 static NSString *ID = @"cell";
 UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
 if (!cell) {
  cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
 }
 //初始化cell數(shù)據(jù)!
 [cell.textLabel setText:@"阿偉"];
 [cell.detailTextLabel setText:@"2016-03-22"];

 return cell;
}

//滾動(dòng)tableview 完畢之后
-(void)scrollViewDidScroll:(UIScrollView *)scrollView{

 //圖片高度
 CGFloat imageHeight = self.headerBackView.frame.size.height;
 //圖片寬度
 CGFloat imageWidth = kScreenWidth;
 //圖片上下偏移量
 CGFloat imageOffsetY = scrollView.contentOffset.y;

 NSLog(@"圖片上下偏移量 imageOffsetY:%f ->",imageOffsetY);



 //上移
 if (imageOffsetY < 0) {
  CGFloat totalOffset = imageHeight + ABS(imageOffsetY);
  CGFloat f = totalOffset / imageHeight;

  self.headerImageView.frame = CGRectMake(-(imageWidth * f - imageWidth) * 0.5, imageOffsetY, imageWidth * f, totalOffset);
 }

// //下移
// if (imageOffsetY > 0) {
//  CGFloat totalOffset = imageHeight - ABS(imageOffsetY);
//  CGFloat f = totalOffset / imageHeight;
//  
//  [self.headerImageView setFrame:CGRectMake(-(imageWidth * f - imageWidth) * 0.5, imageOffsetY, imageWidth * f, totalOffset)];
// }


}


- (void)didReceiveMemoryWarning {
 [super didReceiveMemoryWarning];
 // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
}
*/

@end

以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • iOS支付寶使用方法詳解

    iOS支付寶使用方法詳解

    這篇文章主要為大家詳細(xì)介紹了iOS支付寶的使用方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-01-01
  • 詳解iOS設(shè)置字體的三種方式

    詳解iOS設(shè)置字體的三種方式

    這篇文章主要介紹了iOS設(shè)置字體的三種方式,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2019-04-04
  • iOS實(shí)現(xiàn)電商購物車界面示例

    iOS實(shí)現(xiàn)電商購物車界面示例

    這篇文章主要為大家詳細(xì)介紹了iOS實(shí)現(xiàn)一個(gè)類似電商購物車界面示例,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-12-12
  • 舉例講解iOS應(yīng)用開發(fā)中對(duì)設(shè)計(jì)模式中的策略模式的使用

    舉例講解iOS應(yīng)用開發(fā)中對(duì)設(shè)計(jì)模式中的策略模式的使用

    這篇文章主要介紹了iOS應(yīng)用設(shè)計(jì)中對(duì)設(shè)計(jì)模式中的策略模式的使用,示例代碼為傳統(tǒng)的Objective-C語言,需要的朋友可以參考下
    2016-03-03
  • iOS版微信朋友圈識(shí)別圖片位置信息 如何實(shí)現(xiàn)?

    iOS版微信朋友圈識(shí)別圖片位置信息 如何實(shí)現(xiàn)?

    這篇文章主要為大家詳細(xì)介紹了iOS版微信朋友圈識(shí)別圖片位置信息的實(shí)現(xiàn)方法
    2016-10-10
  • iOS實(shí)現(xiàn)圓角箭頭視圖

    iOS實(shí)現(xiàn)圓角箭頭視圖

    這篇文章主要為大家詳細(xì)介紹了iOS實(shí)現(xiàn)圓角箭頭視圖,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-04-04
  • iOS組件化開發(fā)實(shí)戰(zhàn)記錄

    iOS組件化開發(fā)實(shí)戰(zhàn)記錄

    這篇文章主要給大家介紹了關(guān)于iOS組件化開發(fā)的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-02-02
  • iOS實(shí)現(xiàn)折疊單元格

    iOS實(shí)現(xiàn)折疊單元格

    這篇文章主要為大家詳細(xì)介紹了iOS實(shí)現(xiàn)折疊單元格,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2020-09-09
  • ios開發(fā)加載webview顯示進(jìn)度條實(shí)例

    ios開發(fā)加載webview顯示進(jìn)度條實(shí)例

    本篇文章主要介紹了ios開發(fā)加載webview顯示進(jìn)度條實(shí)例,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-05-05
  • iOS 設(shè)置View陰影效果

    iOS 設(shè)置View陰影效果

    本文通過實(shí)例代碼給大家講解了iOS 設(shè)置View陰影效果,代碼簡單易懂非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2018-05-05

最新評(píng)論