github:https://github.com/potato512/SYAnimation
使用CATransition進行視圖控制器的轉場動畫自定義。
效果圖:

代碼示例:
// 轉場動畫
CATransition *animation = [CATransition animation];
animation.duration = 0.6;
animation.fillMode = kCAFillModeForwards;
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault];
// 轉場效果-動畫類型type 動畫方向subtype
if (0 == indexPath.row)
{
animation.type = @"cube";
animation.subtype = kCATransitionFromLeft;
}
else if (1 == indexPath.row)
{
animation.type = @"moveIn";
animation.subtype = kCATransitionFromLeft;
}
else if (2 == indexPath.row)
{
animation.type = @"reveal";
animation.subtype = kCATransitionFromLeft;
}
else if (3 == indexPath.row)
{
animation.type = @"fade";
animation.subtype = kCATransitionFromLeft;
}
else if (4 == indexPath.row)
{
animation.type = @"pageCurl";
animation.subtype = kCATransitionFromLeft;
}
else if (5 == indexPath.row)
{
animation.type = @"pageUnCurl";
animation.subtype = kCATransitionFromRight;
}
else if (6 == indexPath.row)
{
animation.type = @"suckEffect";
animation.subtype = kCATransitionFromLeft;
}
else if (7 == indexPath.row)
{
animation.type = @"rippleEffect";
animation.subtype = kCATransitionFromLeft;
}
else if (8 == indexPath.row)
{
animation.type = @"oglFlip";
animation.subtype = kCATransitionFromLeft;
}
else if (9 == indexPath.row)
{
animation.type = @"rotate";
animation.subtype = @"90cw";
}
else if (10 == indexPath.row)
{
animation.type = @"push";
animation.subtype = kCATransitionFromLeft;
}
else if (11 == indexPath.row)
{
animation.type = @"cameraIrisHollowOpen";
animation.subtype = kCATransitionFromLeft;
}
else if (12 == indexPath.row)
{
animation.type = @"cameraIrisHollowClose";
animation.subtype = kCATransitionFromLeft;
}
else if (13 == indexPath.row)
{
animation.type = @"kCATransitionFade";
animation.subtype = kCATransitionFromLeft;
}
else if (14 == indexPath.row)
{
animation.type = @"kCATransitionMoveIn";
animation.subtype = kCATransitionFromLeft;
}
else if (15 == indexPath.row)
{
animation.type = @"kCATransitionPush";
animation.subtype = kCATransitionFromLeft;
}
else if (16 == indexPath.row)
{
animation.type = @"kCATransitionReveal";
animation.subtype = kCATransitionFromLeft;
}
// 添加轉場動畫到導航視圖控制上
[self.navigationController.view.layer addAnimation:animation forKey:nil];