最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

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

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

代碼:

//
// 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;
/** 個人信息界面 */
@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{
 // 不加此句時,在二級欄目點(diǎn)擊返回時,此行會由選中狀態(tài)慢慢變成非選中狀態(tài)。
 // 加上此句,返回時直接就是非選中狀態(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;
}

//滾動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)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • 使用SDLocalize實(shí)現(xiàn)高效完成iOS多語言工作

    使用SDLocalize實(shí)現(xiàn)高效完成iOS多語言工作

    這篇文章主要介紹了使用SDLocalize實(shí)現(xiàn)高效完成iOS多語言工作的相關(guān)資料,需要的朋友可以參考下
    2022-10-10
  • iOS編寫下拉刷新控件

    iOS編寫下拉刷新控件

    這篇文章主要介紹了iOS編寫下拉刷新控件的相關(guān)資料,iOS如何寫個普通的下拉刷新的控件,需要了解的朋友可以參考下文
    2016-04-04
  • Objective-C中字符串的拼接方法小結(jié)

    Objective-C中字符串的拼接方法小結(jié)

    這篇文章主要介紹了Objective-C中字符串的拼接方法小結(jié),除了依靠NSString,文中還介紹了在宏里拼接字符串的方法,需要的朋友可以參考下
    2016-02-02
  • iOS開發(fā)之導(dǎo)航欄各種右滑返回失效的解決方法匯總

    iOS開發(fā)之導(dǎo)航欄各種右滑返回失效的解決方法匯總

    這篇文章主要給大家總結(jié)介紹了關(guān)于iOS開發(fā)教程之導(dǎo)航欄各種右滑返回失效的解決方法,文中通過示例代碼介紹的非常詳細(xì),對各位iOS具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2018-08-08
  • iOS實(shí)現(xiàn)按鈕點(diǎn)擊選中與被選中切換功能

    iOS實(shí)現(xiàn)按鈕點(diǎn)擊選中與被選中切換功能

    這篇文章主要介紹了iOS實(shí)現(xiàn)按鈕點(diǎn)擊選中與被選中切換功能,需要的朋友可以參考下
    2017-07-07
  • iOS實(shí)現(xiàn)自定義起始時間選擇器視圖

    iOS實(shí)現(xiàn)自定義起始時間選擇器視圖

    本篇文章主要介紹了iOS實(shí)現(xiàn)自定義起始時間選擇器視圖,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-06-06
  • iOS高仿微信表情輸入功能代碼分享

    iOS高仿微信表情輸入功能代碼分享

    最近項(xiàng)目需求,要實(shí)現(xiàn)一個類似微信的的表情輸入功能,今天小編抽空給大家分享iOS高仿微信表情輸入功能代碼,非常不錯,感興趣的朋友參考下吧
    2016-11-11
  • iOS10全新推送功能實(shí)現(xiàn)代碼

    iOS10全新推送功能實(shí)現(xiàn)代碼

    這篇文章主要為大家詳細(xì)介紹了iOS10全新推送功能實(shí)現(xiàn)代碼,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2016-09-09
  • iOS NSNotificationCenter通知中心使用小結(jié)

    iOS NSNotificationCenter通知中心使用小結(jié)

    IOS中經(jīng)常會使用到NSNotification和delegate來進(jìn)行一些類之間的消息傳遞,這篇文章主要介紹了iOS NSNotificationCenter使用小結(jié),小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-11-11
  • MAC系統(tǒng)下安裝FFmpeg的圖文教程

    MAC系統(tǒng)下安裝FFmpeg的圖文教程

    這篇文章主要給大家介紹了關(guān)于如何在MAC系統(tǒng)下安裝FFmpeg的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-03-03

最新評論

南漳县| 芒康县| 沂南县| 镇沅| 延津县| 伊宁市| 保定市| 枣阳市| 新蔡县| 平江县| 泰安市| 勃利县| 龙胜| 城固县| 象州县| 永康市| 阜平县| 凤山县| 丽水市| 东安县| 泰州市| 深州市| 陇川县| 永顺县| 丰县| 元江| 绿春县| 肃南| 德安县| 托克托县| 丹寨县| 常州市| 昭苏县| 南靖县| 永登县| 高台县| 垫江县| 锦屏县| 靖州| 沈丘县| 乌兰县|