我做了一个动画,淡入并淡出一个单元格。当我按下单元格(整个单元格上的一个按钮)时,动作通过collectionView上的协议委托并弹出到另一个控制器(detailController)。
细胞
- (IBAction)cellButtonPressed:(id)sender {
[self fadeIn];
}
-(void)fadeIn {
[UIView animateWithDuration:0.5
delay:0.0
options:0.0
animations:^{
self.coverAlbumPhoto.alpha = 0.0f;
self.shadowView.alpha = 0.0f;
self.mountainBorderImageView.alpha = 0.0f;
} completion:^(BOOL finished) {
[self fadeOut];
}];
}
-(void)fadeOut {
[UIView animateWithDuration:0.5
delay:0.0
options:0.0
animations:^{
self.coverAlbumPhoto.alpha = 1.0f;
self.shadowView.alpha = 1.0f;
self.mountainBorderImageView.alpha = 1.0f;
} completion:^(BOOL finished) {
if ([self.delegate respondsToSelector:@selector(tapCellButtonAtIndexPath:)]) {
[self.delegate tapCellButtonAtIndexPath:self.indexPath];
}
}];
}
收藏视图
(void)tapCellButtonAtIndexPath:(NSIndexPath *)indexPath {
ArtworkModel *artworkModel = (ArtworkModel *)[listOfArtworks objectAtIndex:indexPath.row];
FBWorkDetailsViewController *dvc = [[FBWorkDetailsViewController alloc] initWithArtwork:artworkModel];
FBLeftMenuViewController *left = [[FBLeftMenuViewController alloc] init];
MFSideMenuContainerViewController *container = [MFSideMenuContainerViewController
containerWithCenterViewController: dvc
leftMenuViewController: left
rightMenuViewController:nil
withHeader: YES];
[container.titleLabel setText:@"WORK DETAILS"];
[self.navigationController pushViewController: container animated: YES];
}
问题是动画太慢了。谁能解释一下为什么?感谢。
答案 0 :(得分:3)
你有2个动画,每个动画的持续时间为.5秒。这总持续时间为1秒。如果您希望它更快,请使用更短的持续时间。总动画时间为.2到.3秒可能是一个很好的起点,所以请尝试将每个步骤的持续时间缩短为0.15秒(总共0.3秒)。