-(IBAction)move:(UIButton *) button { [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:0.5]; // 不允许直接修改某个对象的结构体成员 CGRect tempFrame = self.image.frame; if (button.tag == 1) { // 上 NSLog(@"上"); tempFrame.origin.y = tempFrame.origin.y - 10; } else if (button.tag == 2) { // 右 NSLog(@"右"); tempFrame.origin.x = tempFrame.origin.x + 10; } else if (button.tag == 3) { // 下 NSLog(@"下"); tempFrame.origin.y = tempFrame.origin.y + 10; } else if (button.tag == 4) { // 左 NSLog(@"左"); tempFrame.origin.x = tempFrame.origin.x - 10; } self.image.frame = tempFrame; [UIView commitAnimations]; }