超简单的UITableView下拉放大的动画
来源:互联网 发布:软件项目质量控制 编辑:程序博客网 时间:2024/06/05 02:07
很多主流的app都会有这个动画,然后用最简单的思想实现了一下,就是按照tableView的contentOffset,直接进行缩放,效果还不错.
#import "ViewController.h"#import <Masonry/Masonry.h>@interface ViewController ()<UITableViewDataSource, UITableViewDelegate>@property (nonatomic, strong) UITableView *tableView;@property (nonatomic, strong) UIImageView *imageView;@property (nonatomic, strong) UITableViewCell *headerCell;@end@implementation ViewController- (void)viewDidLoad { [super viewDidLoad]; //让automaticallyAdjustsScrollViewInsets为NO,是为了当有导航栏的时候,防止系统自动设置tableView的contentInset,这里并没有加navigationController //self.automaticallyAdjustsScrollViewInsets = NO; [self.view addSubview:self.tableView]; // Do any additional setup after loading the view, typically from a nib.}- (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated.}- (UITableView *)tableView{ if (!_tableView) { _tableView = [[UITableView alloc] initWithFrame:self.view.frame]; _tableView.delegate = self; _tableView.dataSource = self; [_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"]; } return _tableView;}- (UIImageView *)imageView{ if (!_imageView) { _imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"user_bg"]]; _imageView.clipsToBounds = YES; } return _imageView;}- (UITableViewCell *)headerCell{ if (!_headerCell) { _headerCell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"headerCell"]; //创建第一个view当做背景,令其clipsToBounds属性为yes,让imageView超出view的部分切掉 UIView *view = [[UIView alloc] init]; view.backgroundColor = [UIColor whiteColor]; view.clipsToBounds = YES; //给view加上左,右,下三个方向上的约束 [_headerCell.contentView addSubview:view]; [view mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(_headerCell.contentView); make.right.equalTo(_headerCell.contentView); make.bottom.equalTo(_headerCell.contentView); }]; [view addSubview:self.imageView]; [self.imageView mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.equalTo(view); }]; } return _headerCell;}#pragma mark - UITableViewDataSource- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return 20;}- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ if (indexPath.row == 0) { return self.headerCell; } UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"]; cell.textLabel.text = [NSString stringWithFormat:@"zhhh%ld",indexPath.row]; return cell;}- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ if (indexPath.row == 0) { return 200; } return 44;}#pragma mark - UIScrollViewDelegate- (void)scrollViewDidScroll:(UIScrollView *)scrollView{ //利用contentOffset.y进行动画 if (scrollView.contentOffset.y < 0) { self.imageView.transform = CGAffineTransformMakeScale(1 - (scrollView.contentOffset.y / self.view.frame.size.width), 1 - (scrollView.contentOffset.y / self.view.frame.size.width)); }}@end
0 0
- 超简单的UITableView下拉放大的动画
- [IOS]对UITableView的简单封装,实现了下拉放大头部图片的效果
- 动画 简单的放大收缩
- iOS编程——最简单的实现UITableView下拉时顶部图片放大消失的效果
- UITableView 自定义的索引View点击放大动画
- UITableView透视图下拉放大.
- UITableView下拉放大效果
- UITableView 下拉放大
- UIView的放大动画
- 简单的css动画下拉菜单
- 下拉放大图片的效果
- UITableView下拉刷新的使用
- UItableview的下拉刷新实现
- iOS UITableView的下拉刷新
- ObjectAnimator动画放大的问题
- 动画特效十:下拉放大
- iOS如何完美简单实现UITableView索引的放大悬浮提示View显示
- 下拉UITableview实现图片放大效果
- 【虫师--系列】JMeter 聚合报告之 90% Line 参数说明
- iOS开发之UITableviewCell实现两个圆角
- Android中的录音与音频合成
- java好书下载
- NSDictionary、NSMutableDictionary的基本用法
- 超简单的UITableView下拉放大的动画
- C# 读取机器码,CPU序列号,生成注册码类(优化)
- NDK学习(一)
- 使用SiteMesh分割、装饰jsp页面
- 【虫师--系列】JMeter基础之--元件的作用域与执行顺序
- 安装VMWare Workstation期间使用默认的HTTPS Port 443结果出现:This port is in use by another program
- 任何类都有这个方法 isEqual
- 多线程之NSThread
- JDBC连接mysql数据库