直接代码
@interface ViewController ()
@property(nonatomic,strong)NSMutableArray *array;
@property(nonatomic,strong)NSMutableArray *viewArr;
@property(nonatomic, strong)UIView *vie;
@property(nonatomic)CGPoint upCenter;
@property(nonatomic,strong)NSTimer *timer;
@property(nonatomic, assign)int moveX;
@property(nonatomic, assign)int moveY;
@end
@implementation ViewController
- (IBAction)clicked:(UIButton *)sender {
switch (sender.tag) {
case 0://上
{
self.moveX=0;
self.moveY=-30;
}
break;
case 1://下
{
self.moveX=0;
self.moveY=30;
}
break;
case 2://左
{ self.moveX=-30;
self.moveY=0;
}
break;
case 3://右
{
self.moveX=30;
self.moveY=0;
}
break;
}
}