今天老李问我,天天cell,天天cell,真没意思,想想也是,早几年,精通个tableview就差不多可以找到不错的工作了,到现在,天天面对的还是tableView,collectionView,觉得不弄点花样真的没啥意思了,突然想写个库,方便自己也方便大家嘛,写完了会放到这里,给大家随便用,但是刚着手,没写完呢,今天就是记录下几个系统给的cell动画。
日常两种方式。
第一种是老的(个人感觉淘汰了好久了)
[UIView beginAnimation:]和[UIView commitAnimation]
直接上代码了
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[UIView beginAnimations:@"JackYangAnimationId" context:nil];//开始发起动画
[UIView setAnimationDuration:0.5f];//动画时间
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];//动画曲线
[UIView setAnimationRepeatAutoreverses:NO];//是否重复
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:[tableView cellForRowAtIndexPath:indexPath] cache:YES];//动画样式 以及 对于哪个view来说,这里自然对于选中的cell来说了
[UIView commitAnimations];//提交动画
[self performSelector:@selector(somethingYouWillDo) withObject:nil afterDelay:0.5f];//这里是等动画执行完毕之后,你可以在somethingYouWillDo
//或者 直接使用GCD 的延时函数 dispatch_after 两种都可以,目的是等动画结束在执行操作
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
//里面执行你要操作
});
}
或者,直接上第二种block动画,这种动画是现在苹果主要推崇的
<span style="font-size:24px;">[UIView transitionWithView:[tableView cellForRowAtIndexPath:indexPath] duration:0.8 options:UIViewAnimationOptionCurveEaseInOut animations:^{
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:[tableView cellForRowAtIndexPath:indexPath] cache:YES];
} completion:^(BOOL finished) {
//这里填写你想做完动画后的操作。
}];</span>
其中 setAnimationTransition:的参数就是 几个 系统自带的动画模式
<span style="font-size:24px;">typedef NS_ENUM(NSInteger, UIViewAnimationTransition) {
UIViewAnimationTransitionNone,
UIViewAnimationTransitionFlipFromLeft,
UIViewAnimationTransitionFlipFromRight,
UIViewAnimationTransitionCurlUp,
UIViewAnimationTransitionCurlDown,
};</span>
就这些了,系统给的终究还是太low了,明天开始上代码,写了两个效果了,注释对我来说真的是受罪、