#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@property (weak, nonatomic) IBOutlet UIButton *button;
/*
//实现点击向上的方法
- (IBAction)up:(id)sender;
//实现点击向下的方法
- (IBAction)lower:(id)sender;
//实现点击向右的方法
- (IBAction)right:(id)sender;
//实现点击向左的方法
- (IBAction)left:(id)sender;
*/
//上下左右移动的方法实现 利用tag,和if或者switch条件语句
- (IBAction)run:(id)sender;
//旋转方法的实现 利用tag 利用if语句
- (IBAction)rotate:(id)sender;
//伸缩的方法实现 利用tag 利用三目运算
- (IBAction)telescopic:(id)sender;
@end
#import "ViewController.h"
#define kdelta 20
@interface ViewController ()
@end
@implementation ViewController
/*
#pragma mark 向上走的实现方法
- (IBAction)up:(id)sender {
//添加动画,是为了让效果更好看,用法就是把这个方法上下包住
//动画是一个UIView的类方法,[UIView beginAnimations:(NSString *) context:(void *)]; 在大部分情况下,(NSString *) 和(void *)都直接为空
//动画开始,是慢慢的执行
[UIView beginAnimations:nil context:nil];
//设置动画的执行时间,也是一个UIView类方(是double类型,所以有小数点)
[UIView setAnimationDuration:2.0]; // 时间是以秒为单位。这个类方法的意思就是y值,点击向上一次的时间是2秒,这个可以随便修改
//两种获得button这个属性的方法,为什么要获得button能,因为最后是要控制这个button,所以要获得它
//_button;// 这个是获得button第一种方法
//因为要控制button向上走,所以是控制y值(y值是向上向下,x值是向左向右),而这个x和y值都是在frame属性中,frame是UIButton中得属性,而UIButton是继承UIView
//self.button;// 这个是获得button第二种方法