UITableViewCell动画效果
* pod 'MXAnimationCell'
* #import "MXAnimationCellManager.h"
* 将MXAnimationCellClass文件夹内容添加到项目中
* #import "MXAnimationCellManager.h"
//绑定展示动画的tableView
[MXAnimationCellManager shareInstance].tableView = _tableView;
//指定动画类型
[MXAnimationCellManager shareInstance].type = MXCellAnimationExpand;
//在需要显示动画的地方调用show方法
[[MXAnimationCellManager shareInstance] show];
/*ViewController.m*/
#import "MXAnimationCellManager.h"
@interface ViewController ()<UITableViewDelegate, UITableViewDataSource> {
UITableView *_tableView;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"MXAnimationCellDemo";
_tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height) style:UITableViewStylePlain];
_tableView.delegate = self;
_tableView.dataSource = self;
[self.view addSubview:_tableView];
[MXAnimationCellManager shareInstance].tableView = _tableView;
[MXAnimationCellManager shareInstance].type = MXCellAnimationExpand;
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(refreshTableView)];
}
- (void)refreshTableView {
[[MXAnimationCellManager shareInstance] show];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 30;
}
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellID = @"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
if (!cell) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
}
cell.textLabel.text = [NSString stringWithFormat:@"Row %ld",indexPath.row];
cell.contentView.backgroundColor = [UIColor orangeColor];
return cell;
}
@end