在项目中,经常要做动画效果,比如我最近项目中做3D旋转的动画,在某一个cell中对其进行旋转主要用到的就是CATransform3D里面的
CATransform3D CATransform3DMakeRotation (CGFloat angle, CGFloat x, CGFloat y, CGFloat z)
// zhangqing cell 翻转动画 重置热词中
-(void)animationRefreshCellInfo:(UISearchLabelCell_Iphone *)cell arrData:(NSMutableArray *)arr{
[cell setHotWordCellInfo:nil lastArrCount:lastHotWordsCout];
CATransform3D transform;
transform = CATransform3DMakeRotation( (180.0*M_PI)/180, 0, 1, 0);
transform.m34 = 1.0/ -600;
//定义cell的初始状态
cell.layer.shadowColor = [[UIColor blackColor]CGColor];
cell.layer.shadowOffset = CGSizeMake(10, 10);
cell.alpha =1;
cell.layer.transform = transform;
cell.layer.anchorPoint = CGPointMake(0.5, 0.5);
//定义cell的最终状态,并提交动画
[UIView beginAnimations:@"transform" context:NULL];
[UIView setAnimationDuration:0.8];
cell.layer.transform = CATransform3DIdentity;
cell.alpha =1;
cell.layer.shadowOffset = CGSizeMake(0, 0);
cell.frame = CGRectMake(0, cell.frame.origin.y, cell.frame.size.width, cell.frame.size.height);
[UIView commitAnimations];
__block UISearchLabelCell_Iphone *tmpCell=cell;
[self performBlock:^{
[tmpCell setHotWordCellInfo:arr lastArrCount:lastHotWordsCout];
} afterDelay:0.4];
isResetTapped=NO;
lastHotWordsCout=[arr count];
}
//zhangqing
- (void)performBlock:(void (^)(void))block afterDelay:(NSTimeInterval)delay{
block = [[block copy] autorelease];
[self performSelector:@selector(fireBlockAfterDelay:)
withObject:block
afterDelay:delay];
}
//zhangqing
- (void)fireBlockAfterDelay:(void (^)(void))block {
block();
}
//zhangqing 重置热词事件
-(void)tappedResetHotWord:(id)sender{
NSMutableArray *arr=[self setHotWordsShowInTableView:sender];
dataResetCout++;
isResetTapped=YES;
if (IS_PHONE) {
NSIndexPath *index=[NSIndexPath indexPathForRow:0 inSection:0];
UISearchLabelCell_Iphone *cell=(UISearchLabelCell_Iphone *)[_myTableView cellForRowAtIndexPath:index];
[self animationRefreshCellInfo:cell arrData:arr];
// [self reloadMyTableViewForRow:0 section:0];
}else{
[hotwordsDataTable animationRefreshCellInfo:arr];
isResetTapped=NO;
}
}