头部图片可伸缩的TableView
来源:互联网 发布:购物车数据在哪里看 编辑:程序博客网 时间:2024/05/10 19:26
Table列表顶部是一张大图,大图可以随着列表的下拉而放大。
其中IScrollView的代理方法scrollViewDidScroll是重点方法。
#import "ViewController.h"
#define Imgwidth 828
#define Imgheight 589
#define ScaleImageViewHeight ([UIScreen mainScreen].bounds.size.width*Imgheight/Imgwidth)
@interface
ViewController
()<
UITableViewDelegate
,
UITableViewDataSource
,UIScrollViewDelegate>
@property
(strong,
nonatomic
)
IBOutlet
UIImageView
*scaleImageView;
@property
(weak,
nonatomic
)
IBOutlet
UITableView
*tableView;
@property
(strong,
nonatomic
)
IBOutlet
UIImageView
*noScaleImage;
@property
(strong,
nonatomic
)
IBOutlet
UILabel
*nicknameLabel;
@end
@implementation
ViewController
- (
void
)viewDidLoad {
[
super
viewDidLoad
];
self
.tableView
.delegate
=
self
;
self
.tableView
.dataSource
=
self
;
}
- (
void
)viewWillAppear:(
BOOL
)animated
{
self
.tableView
.contentInset
= UIEdgeInsetsMake(
ScaleImageViewHeight
,
0
,
0
,
0
);
self
.scaleImageView
.frame
= CGRectMake(
0
, -
ScaleImageViewHeight
,
self
.view
.frame
.size
.width
, ScaleImageViewHeight);
[
self
.tableView
addSubview
:
self
.scaleImageView
];
self
.noScaleImage
.frame
= CGRectMake(
2
0
, -
5
0
,
4
8
,
4
8
);
[
self
.tableView
addSubview
:
self
.noScaleImage
];
self
.nicknameLabel
.frame
= CGRectMake(
8
8
, -
4
2
,
8
0
,
3
0
);
[
self
.tableView
addSubview
:
self
.nicknameLabel
];
}
#pragma - mark UIScrollView Delegate
- (
void
)scrollViewDidScroll:(
UIScrollView
*)scrollView
{
CGFloat
y = scrollView
.contentOffset
.y
;
if
(y < -ScaleImageViewHeight)
{
CGRect
frame =
self
.scaleImageView
.frame
;
frame
.size
.height
= -y;
frame
.origin
.y
= y;
self
.scaleImageView
.frame
= frame;
}
}
#pragma - mark UITableView DataSource
- (NSInteger)tableView:(
UITableView
*)tableView
numberOfRowsInSection
:(NSInteger)section
{
return
2
0
;
}
- (
UITableViewCell
*)tableView:(
UITableView
*)tableView
cellForRowAtIndexPath
:(
NSIndexPath
*)indexPath
{
UITableViewCell
*cell = [tableView
dequeueReusableCellWithIdentifier
:
@"cell"
];
cell
.textLabel
.text
= [@(indexPath
.row
)
stringValue
];
return
cell;
}
@end
0 0
- 头部图片可伸缩的TableView
- iOS 伸缩的头部tableView
- 一种可展开伸缩的tableView实现
- 自定义View之头部可伸缩的ListView
- tableview下拉的时候,头部图片放大效果view下拉的时候,头部图片放大效果
- 关于Tableview头部添加图片或者其他东西的时候
- TableView头部图片下拉图片放大
- 通过UIEdgeInsetsMake来制作可伸缩的Button(图片拉伸)
- JavaScript 30 Day -- 04 可伸缩的图片墙
- 可伸缩的电子商务解决方案
- 可伸缩的TextView
- 可伸缩的TextView
- 浅谈viewpager嵌套tablayout + 头部可伸缩view
- QQ空间头部图片可拉伸的ListView效果
- 图片的局部伸缩
- 可伸缩的电子商务解决方案 2
- 可伸缩的搜索框
- Android ----可伸缩的控件
- 【javaweb】左边选择右边展现的tld
- DM8148 开发记录
- Error Correction
- IBM Juices Hadoop With Java On Tesla GPUs
- atoi() & itoa()函数的内部的实现
- 头部图片可伸缩的TableView
- 视频压缩编码基本原理
- markdown常用格式一览
- 软件代码数字签名基本原理
- VC++在一个类中调用另一个类中的函数
- 不能说的秘密:UEditor和UltraEdit
- 总结近期所学的几种排序方法的基本思想
- jqGrid的filterToolbar设置默认option
- D3js-中国各主要大城市经纬度数据