- (IBAction)move:(UIButton *)btn
{
// center (x=200, y=10)
// center (x=200, y=210)
// 0.开始动画
[UIViewbeginAnimations:nilcontext:nil];
// 动画持续2秒
[UIViewsetAnimationDuration:2.0];
// 1.取出原来的属性
CGPoint tempCenter =self.head.center;
// 2.修改临时属性
CGFloat delta =200;
switch (btn.tag) {
case10: //上
tempCenter.y -= delta;
break;
case20: //下
tempCenter.y += delta;
break;
case30: //左
tempCenter.x -= delta;
break;
case40: //右
tempCenter.x += delta;
break;
}
// 3.重新赋值
self.head.center = tempCenter;
// 4.提交动画
[UIViewcommitAnimations];
}
1.NSBundle
1> 一个NSBundle代表一个文件夹,利用NSBundle能访问对应的文件夹
2>利用mainBundle就可以访问软件资源包中的任何资源
3>模拟器应用程序的安装路径
/Users/aplle/资源库/Application Support/iPhone Simulator/7.1/Applications
2.UIImageView和UIButton
1>使用场合
* UIImageView:如果仅仅是显示图片,不需要监听图片的点击
* UIButton:既要显示图片,又要监听图片的点击
2>相同:能显示图片
3> 不同点
* UIButton能处理点击事件, UIImageView不能处理点击事件
* UIButton既能显示图片,又能显示文字
* UIButton能同时显示两张图片
* UIButton继承自UIControl,因此默认就能处理事件
* UIImageView继承自UIView,因此默认就不能处理事件
3.Xcode文档安装路径
/Applications/Xcode.app/Contents/Developer/Documentation/DocSets
4.Xcode模拟器安装路径
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs