IOS简单的动画
来源:互联网 发布:网络门禁系统图 编辑:程序博客网 时间:2024/05/05 08:18
前言
在IOS客户端开发中,用到动画的地方比较少,如果是要把app做的很酷炫,那么就有必要用一些动画效果。
一、最普通的动画
1、下面这段代码是最简单的动画,只是实现了简单的位置移动和变化
- (void)viewDidLoad { [super viewDidLoad]; UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)]; imgView.image = [UIImage imageNamed:@"123.jpg"]; [self.view addSubview:imgView]; [UIView beginAnimations:nil context:nil]; //设置动画开始 [UIView setAnimationDuration:3.0];//设置整个动画的时间 CGRect frame = imgView.frame; frame.origin.x += 150; frame.origin.y += 100; [imgView setFrame:frame]; [UIView commitAnimations]; //动画结束 }
这种动画,我觉得可以通俗的理解为视图或者控件出场的动画效果。
- (void)viewDidLoad { [super viewDidLoad]; UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)]; imgView.image = [UIImage imageNamed:@"123.jpg"]; [self.view addSubview:imgView]; CATransition *animation = [CATransition animation]; animation.duration = 0.5f; //设置动画的时间 animation.timingFunction = UIViewAnimationCurveEaseInOut; //设置动画的方式 animation.fillMode = kCAFillModeBackwards; animation.type = kCATransitionMoveIn; animation.subtype = kCATransitionFromLeft; [imgView.layer addAnimation:animation forKey:@"animation"]; }
3、先变大后消失的动画效果
- (void)viewDidLoad { [super viewDidLoad]; UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)]; imgView.image = [UIImage imageNamed:@"123.jpg"]; [self.view addSubview:imgView]; [UIView animateWithDuration:3.25 animations:^{ CGAffineTransform newTransform = CGAffineTransformMakeScale(2.2, 2.2); [imgView setTransform:newTransform]; }completion:^(BOOL finished){ [imgView removeFromSuperview]; }];}
0 0
- IOS简单的动画
- ios 的简单动画
- ios 简单的图片动画
- iOS 简单的动画连接
- IOS常用的简单动画
- iOS简单好看的动画
- ios简单动画的实现
- iOS动画的简单使用
- iOS-实现简单的动画效果
- iOS 简单的播放gif动画
- ios 交换两个uiview的简单动画
- iOS 动画效果。简单的提示消失
- IOS 简单的 加减分 动画
- 简单说说iOS的图形和动画
- iOS 简单的播放gif动画
- ios气泡动画效果的简单实现
- IOS中UIView动画的简单实现
- IOS autoLayout 简单的使用动画效果
- org.springframework.beans.factory.config.PropertyPlaceholderConfigurer
- 线程函数的设计以及MsgWaitForMultipleObjects函数的使用要点
- Populating Next Right Pointers in Each Node II
- Mac OS X开启root用户
- 技术领导力:作为技术团队领导经常为人所忽略的技能和职责
- IOS简单的动画
- ubuntu中如何将终端命令添加到右键
- LCS之最长公共子串
- IIS7.5 报错 HTTP 错误 404.0- Not Found 您要找的资源已被删除、已更名或暂时不可用 解决方案···
- css-FIRST-CHILD 说明
- end_cms记录(1)
- mysql修改字符集
- 使用 vmware+windbg 分析调试 windows 7 内核
- JavaScript跨域方法学习总结