点击cell动态修改高度动画

效果

源码

https://github.com/YouXianMing/Animations

//
// TapCellAnimationController.m
// Animations
//
// Created by YouXianMing on 16/4/8.
// Copyright © 2016年 YouXianMing. All rights reserved.
// #import "TapCellAnimationController.h"
#import "ShowTextCell.h"
#import "ShowTextModel.h"
#import "CellDataAdapter.h"
#import "UIFont+Fonts.h"
#import "UIView+SetRect.h" @interface TapCellAnimationController () <UITableViewDelegate, UITableViewDataSource> @property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSMutableArray *datasArray; @end @implementation TapCellAnimationController - (void)setup { [super setup]; [self createDataSource]; [self buildTableView];
} #pragma mark - DataSource - (void)createDataSource { self.datasArray = [NSMutableArray array]; NSArray *strings = @[
@"AFNetworking is a delightful networking library for iOS and Mac OS X. It's built on top of the Foundation URL Loading System, extending the powerful high-level networking abstractions built into Cocoa. It has a modular architecture with well-designed, feature-rich APIs that are a joy to use. Perhaps the most important feature of all, however, is the amazing community of developers who use and contribute to AFNetworking every day. AFNetworking powers some of the most popular and critically-acclaimed apps on the iPhone, iPad, and Mac. Choose AFNetworking for your next project, or migrate over your existing projects—you'll be happy you did!", @"黄色的树林里分出两条路,可惜我不能同时去涉足,我在那路口久久伫立,我向着一条路极目望去,直到它消失在丛林深处。但我却选了另外一条路,它荒草萋萋,十分幽寂,显得更诱人、更美丽,虽然在这两条小路上,都很少留下旅人的足迹,虽然那天清晨落叶满地,两条路都未经脚印污染。呵,留下一条路等改日再见!但我知道路径延绵无尽头,恐怕我难以再回返。也许多少年后在某个地方,我将轻声叹息把往事回顾,一片树林里分出两条路,而我选了人迹更少的一条,从此决定了我一生的道路。", @"★タクシー代がなかったので、家まで歩いて帰った。★もし事故が発生した场所、このレバーを引いて列车を止めてください。(丁)为了清楚地表示出一个短语或句节,其后须标逗号。如:★この薬を、夜寝る前に一度、朝起きてからもう一度、饮んでください。★私は、空を飞ぶ鸟のように、自由に生きて行きたいと思った。*****为了清楚地表示词语与词语间的关系,须标逗号。标注位置不同,有时会使句子的意思发生变化。如:★その人は大きな音にびっくりして、横から飞び出した子供にぶつかった。★その人は、大きな音にびっくりして横から飞び出した子供に、ぶつかった。", @"Two roads diverged in a yellow wood, And sorry I could not travel both And be one traveler, long I stood And looked down one as far as I could To where it bent in the undergrowth; Then took the other, as just as fair, And having perhaps the better claim, Because it was grassy and wanted wear; Though as for that the passing there Had worn them really about the same, And both that morning equally lay In leaves no step had trodden black. Oh, I kept the first for another day! Yet knowing how way leads on to way, I doubted if I should ever come back. I shall be telling this with a sigh Somewhere ages and ages hence: Two roads diverged in a wood, and I- I took the one less traveled by, And that has made all the difference. ", @"Star \"https://github.com/YouXianMing\" :)"
]; for (int i = ; i < strings.count; i++) { ShowTextModel *model = [[ShowTextModel alloc] init];
model.inputString = strings[i]; [model calculateTheNormalStringHeightWithStringAttribute:@{NSFontAttributeName : [UIFont HeitiSCWithFontSize:.f]} fixedWidth:Width - ];
[model calculateTheExpendStringHeightWithStringAttribute:@{NSFontAttributeName : [UIFont HeitiSCWithFontSize:.f]} fixedWidth:Width - ]; CellDataAdapter *adapter = [CellDataAdapter cellDataAdapterWithCellReuseIdentifier:@"ShowTextCell" data:model
cellHeight:model.normalStringHeight
cellType:kShowTextCellNormalType];
[self.datasArray addObject:adapter];
}
} #pragma mark - UITableView - (void)buildTableView { self.tableView = [[UITableView alloc] initWithFrame:self.contentView.bounds];
self.tableView.delegate = self;
self.tableView.dataSource = self;
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; [self.tableView registerClass:[ShowTextCell class] forCellReuseIdentifier:@"ShowTextCell"];
[self.contentView addSubview:self.tableView];
} - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return self.datasArray.count;
} - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { CellDataAdapter *dataAdapter = self.datasArray[indexPath.row]; CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:dataAdapter.cellReuseIdentifier];
cell.data = dataAdapter.data;
cell.dataAdapter = dataAdapter;
cell.tableView = tableView;
cell.indexPath = indexPath;
[cell loadContent]; return cell;
} - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { ShowTextCell *cell = [tableView cellForRowAtIndexPath:indexPath];
[cell changeState];
} - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { CellDataAdapter *dataAdapter = self.datasArray[indexPath.row]; return dataAdapter.cellHeight;
} @end

细节

点击cell动态修改高度动画的更多相关文章

  1. Swift - 实现点击cell动态修改高度

    Swift - 实现点击cell动态修改高度 效果 源码 https://github.com/YouXianMing/Swift-Animations // // TapCellAnimationC ...

  2. JQuery中点击超链接动态修改url连接地址无效

    这篇随笔的标题真是好拗口,想表达的意思是,当点击超链接后,才去修改超链接的地址,此时超链接仍然链接的是是修改之前的页面,而不是修改之后的页面. 超链接代码如下: <a id="chao ...

  3. html中iframe根据子页面内容动态修改高度

    JavaScript var browserVersion = window.navigator.userAgent.toUpperCase(); var isOpera = browserVersi ...

  4. 使用Autolayout实现UITableView的Cell动态布局和高度动态改变

    本文翻译自:stackoverflow 有人在stackoverflow上问了一个问题: 1 如何在UITableViewCell中使用Autolayout来实现Cell的内容和子视图自动计算行高,并 ...

  5. UITableView自定义Cell中,纯代码编程动态获取高度

    在UITableView获取高度的代理方法中,经常需要根据实际的模型重新计算每个Cell的高度.直接的做法是在该代理方法中,直接根据模型来返回行高:另 [1]-(CGFloat)tableView:( ...

  6. android中动态修改ImageView控件的宽高度

    本例实现了动态修改ImageView控件的宽高度,有两个按钮,一个按钮实现放大image,一个按钮实现缩小image activity_main.xml <?xml version=" ...

  7. 解决点击cell执行动画导致的重用问题

    解决点击cell执行动画导致的重用问题 说明: 动画的细节都是裸露的,并没有封装,靠看官来优化了. 效果: 源码: https://github.com/YouXianMing/UITableView ...

  8. iOS点击cell查看大图,点击大图还原小图-b

    一.项目需求 用collectionView展示很多照片,点击某个照片,用全屏scrollView无限循环的方式查看图片.点击放大的图片,图片缩小到原先的尺寸. 如图gif1.gif所示,点击中间的图 ...

  9. iOS 动态修改导航栏颜色 UINavigationBar

    示例 所谓动态修改  意思是 在当前页面滚动的过程中 亦或 是在 触发返回事件\进入一个新的页面  导航栏的动态变化 由于系统级别的navBar 高度集成  很多自己想实现的功能 很不好弄 如果是通过 ...

随机推荐

  1. docker:定制node.js的版本

    本想用alpine,但如果想使用node.js 6.3.1版本的软件, 总会搞不定glibc和libstdc++报一个无法识别版本信息的错误. 搞了一天,算了.使用debian:stretch-sli ...

  2. nvidia-smi 命令解读

    nvidia-smi 的定义: 基于 NVIDIA Management Library (NVIDIA 管理库),实现 NVIDIA GPU 设备的管理和监控功能 主要支持 Tesla, GRID, ...

  3. ansible学习

    声明:本博客内容是根据惨绿少年内容实践随笔,地址:http://www.cnblogs.com/clsn/p/7743792.html#comment_form 1.ansible介绍 Ansible ...

  4. Eclipse下Maven新建项目、自动打依赖jar包(包含普通项目和Web项目)

    不多说,直接上干货! 当我们无法从本地仓库找到需要的构件的时候,就会从远程仓库下载构件至本地仓库.一般地,对于每个人来说,书房只有一个,但外面的书店有很多,类似第,对于Maven来说,每个用户只有一个 ...

  5. webshpere 节点&环境分析

    场景名称:LotusConnections: 场景下有一个节点:feb02Node1 节点下有一个应用服务器 LotusConnections server.

  6. Python进行Android开发步骤

    移动应用开发 1. 建立开发环境 下载软件开发包(SDK):        http://developer.android.com/sdk/index.html        adt-bundle- ...

  7. python中的*和**参数传递机制

    python的参数传递机制具有值传递(int.float等值数据类型)和引用传递(以字典.列表等非值对象数据类型为代表)两种基本机制以及方便的关键字传递特性(直接使用函数的形参名指定实参的传递目标,如 ...

  8. db 文件 查看 打开 工具 db 中文 版 navicat 中文

    韩梦飞沙  韩亚飞  313134555@qq.com  yue31313  han_meng_fei_sha ======= db 中文 版 navicat 中文 ======= Navicatfo ...

  9. C语言结构体及typedef关键字定义结构体别名和函数指针的应用

    结构体(struct)的初始化 struct autonlist { char *symbol; struct nlist nl[2]; struct autonlist *left, *right; ...

  10. Beyond Compare 4提示已经过了30天试用期,破解方式,亲测可用

    修改注册表 1)在搜索栏中输入 regedit ,打开注册表 2) 删除项目:计算机\HKEY_CURRENT_USER\Software\Scooter Software\Beyond Compar ...