第四天 图像移动《苹果iOS实…
2013-06-09 11:41
363 查看
原文地址:第四天 图像移动《苹果iOS实例编程入门教程》作者:苹果iphonesdk
![](http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif)
//iOS SDK 中的 UIImageView
动态移动动画
运行安装好的 xCode
选择: File->New
Project.
从 'New Project' 窗口
选择 : iPhone OS
->Applications-> Single View
Application
命名 : 这里命名为 “movingImage”
//打开 ViewController.m 文件:
//解开(void)viewDidLoad
- (void)viewDidLoad {
//定义图片的位置和尺寸,位置:x=10.0f, y=10.0f ,尺寸:x=50.0f,
y=40.0f
UIImageView *subview = [[UIImageView alloc]
initWithFrame:
CGRectMake(10.0f, 10.0f, 50.0f, 40.0f)];
//设定图片名称,myPic.png已经存在,拖放添加图片文件到image项目文件夹中
[subview
setImage:[UIImage imageNamed:@"myPic.png"]];
//启用动画移动
[UIImageView
beginAnimations:nil context:NULL];
//移动时间2秒
[UIImageView setAnimationDuration:2];
//图片持续移动
[UIImageView setAnimationBeginsFromCurrentState:YES];
//重新定义图片的位置和尺寸,位置
subview.frame = CGRectMake(60.0, 100.0,200.0, 160.0);
//完成动画移动
[UIImageView
commitAnimations];
//在
View 中加入图片 subview
[self.View addSubview:subview];
//使用后释放图片, 使用iOS5,对像为iOS4.3以上可以忽略这步骤
[subview
release];
}
下载今天程序文件: Day04.zip
文章本人经过修改及测试,希望大家多多交流。欢迎转载,但请注明出处,多珍惜别人的劳动成果,谢谢大家。
一切版权归http://blog.sina.com.cn/iphonesdk 所有
//更多关于iPhone编程的内容可以参阅下书,
链接:
![](http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif)
![](http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif)
//iOS SDK 中的 UIImageView
动态移动动画
运行安装好的 xCode
选择: File->New
Project.
从 'New Project' 窗口
选择 : iPhone OS
->Applications-> Single View
Application
命名 : 这里命名为 “movingImage”
//打开 ViewController.m 文件:
//解开(void)viewDidLoad
- (void)viewDidLoad {
//定义图片的位置和尺寸,位置:x=10.0f, y=10.0f ,尺寸:x=50.0f,
y=40.0f
UIImageView *subview = [[UIImageView alloc]
initWithFrame:
CGRectMake(10.0f, 10.0f, 50.0f, 40.0f)];
//设定图片名称,myPic.png已经存在,拖放添加图片文件到image项目文件夹中
[subview
setImage:[UIImage imageNamed:@"myPic.png"]];
//启用动画移动
[UIImageView
beginAnimations:nil context:NULL];
//移动时间2秒
[UIImageView setAnimationDuration:2];
//图片持续移动
[UIImageView setAnimationBeginsFromCurrentState:YES];
//重新定义图片的位置和尺寸,位置
subview.frame = CGRectMake(60.0, 100.0,200.0, 160.0);
//完成动画移动
[UIImageView
commitAnimations];
//在
View 中加入图片 subview
[self.View addSubview:subview];
//使用后释放图片, 使用iOS5,对像为iOS4.3以上可以忽略这步骤
[subview
release];
}
下载今天程序文件: Day04.zip
文章本人经过修改及测试,希望大家多多交流。欢迎转载,但请注明出处,多珍惜别人的劳动成果,谢谢大家。
一切版权归http://blog.sina.com.cn/iphonesdk 所有
//更多关于iPhone编程的内容可以参阅下书,
链接:
![](http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif)
相关文章推荐
- 如何将IOS App程序发布到苹果… 分类: Android开发 2014-05-30 10:56 76人阅读 评论(0) 收藏
- 第十四天 闹钟《苹果iOS实例…
- 第一天 午夜倒数《苹果iOS实…
- 第二天 营火 《苹果iOS实例…
- ios 第三方苹果开发库之ASIHTTPReq…
- ios 从URL加载图像
- 第三天 打开地图《苹果iOS实…
- 苹果向公测用户发布 iOS&nbsp…
- iOS 将图像数据转换成…
- 如何将IOS App程序发布到苹果…
- 第九天 雪花《苹果iOS实例编…
- IOS学习网址之Core Animation入门
- 【安卓开机动画】苹果Apple i…
- iOS程序发布测试3-生成ad ho…
- iOS 消息推送原理及实现总结
- 【安卓开机动画】苹果apple l…
- iOS 压缩图片的方法
- 【安卓开机动画】苹果apple l…
- 移动终端网页游戏移植研发框架【android&IOS总汇】
- 苹果高管热爆:“Windows 7是个过时的科技玩意”