IOS 动画用法总结

来源:互联网 发布:深圳2年java工作经验 编辑:程序博客网 时间:2024/06/04 01:26

UIView动画基础

setAnimationDelegate:    设置动画代理对象

setAnimationDuration: 设置动画时间长度

setAnimationDelay: 设置动画延时开始时间

setAnimationWillStartSelector: 设置动画开始处理函数

setAnimationDidStopSelector: 设置动画结束处理函数

[UIView beginAnimations:nil context:nil];//开始动画,准备动画的开始工作        //动画的实际目标结果    [UIView setAnimationDuration:2];//设置动画时间函数,参数以秒为单位    [UIView setAnimationDelay:0];//设置动画开始的延迟时间长度,进行延时动画的处理    [UIView setAnimationDelegate:self];//设置动画代理对象    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];//设置移动方式    [UIView setAnimationDidStopSelector:@selector(stopAnim)];    _imageView.frame = CGRectMake(135, 135, 10, 10);        [UIView commitAnimations];//提交运行动画

[UIView beginAnimations:nil context:nil];//开始动画,准备动画的开始工作        //动画的实际目标结果    [UIView setAnimationDuration:2];//设置动画时间函数,参数以秒为单位    [UIView setAnimationDelay:0];//设置动画开始的延迟时间长度,进行延时动画的处理    [UIView setAnimationDelegate:self];//设置动画代理对象    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];//设置移动方式    [UIView setAnimationDidStopSelector:@selector(stopAnim)];    _imageView.frame = CGRectMake(300, 300, 80, 80);        [UIView commitAnimations];//提交运行动画

他是有一个固定的格式:一第一行开头,最后一行结束来创建并且提交动画的






导航控制器动画


CATransition 动画对象

duration 时间长度

type 类型

timingFuction 运动类型

tusubtype       子动画类型



//定义一个动画变化对象,层动画对象    //类方法获取动画对象    CATransition *amin = [CATransition animation];    amin.duration = 2;//设置动画时间长度    amin.type = @"rippleEffect";//设置动画的类型,决定动画的效果形式    amin.subtype = kCATransitionFromLeft;//设置动画的子类型,例如动画的方向    amin.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];//设置动画的轨迹模式    [self.navigationController.view.layer addAnimation:amin forKey:nil];//将动画设置对象添加到动画上
动画的类型有

/* @"rippleEffect" @"cube" @"moveIn" @"reveal" @"fade" @"pageCurl" @"pageUnCurl" @"suckEffect" @"rippleEffect" @"oglFlip" */












原创粉丝点击