iOS中导航控制器动画

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/xiaoxingaiwo/article/details/81660406

先来看下实现的效果的样子

这里写图片描述
视图控制器一代码:

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor=[UIColor whiteColor];
    _imageView=[[UIImageView alloc]init];
    _imageView.frame=CGRectMake(100, 100, 280, 230);
    _imageView.image=[UIImage imageNamed:@"super_light_80"];
    [self.view addSubview:_imageView];
}
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    //定义一个动画变换对象,层动画对象
    CATransition *amin=[CATransition animation];
    //设置动画的时间长长度
    amin.duration=1;  
    //设置主动画类型,决定动画的效果形式
    amin.type=@"cube";
    //设置动画的子类型,例如动画的方向
    amin.subtype=kCATransitionFromLeft;
    //设置动画的轨迹
    amin.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    [self.navigationController.view.layer addAnimation:amin forKey:nil];
    VCSecond *second=[[VCSecond alloc]init];
    [self.navigationController pushViewController:second animated:YES];
}

猜你喜欢

转载自blog.csdn.net/xiaoxingaiwo/article/details/81660406
今日推荐