#import "ViewController.h" @interface ViewController () { UILabel * lable1; UILabel * lable2; CGRect frame1; CGRect frame2; CGRect frame3; NSMutableArray * lableArray; } @property (weak, nonatomic) IBOutlet UIView *bgview; - (IBAction)action:(id)sender; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. lableArray =[NSMutableArray array]; lable1 =[[UILabel alloc]init]; lable2 =[[UILabel alloc]init]; frame1 =CGRectMake(0, -50, 320, 50); frame2 =CGRectMake(0, 0, 320, 50); frame3 =CGRectMake(0, 50, 320, 50); lable1.frame =frame1; lable2.frame =frame2; lable1.text =@"第1個"; lable2.text =@"第2個"; [_bgview addSubview:lable1]; [_bgview addSubview:lable2]; _bgview.clipsToBounds =YES; [lableArray addObject:lable1]; [lableArray addObject:lable2]; NSTimer * timer =[NSTimer scheduledTimerWithTimeInterval:3.5 target:self selector:@selector(Actions:) userInfo:nil repeats:YES]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } -(void)Actions:(id)sender { [UIView animateWithDuration:3.0 animations:^{ UILabel * lab1 =(UILabel*)lableArray[0]; UILabel * lab2 =(UILabel*)lableArray[1]; lab1.frame =frame2; lab2.frame =frame3; } completion:^(BOOL finished) { UILabel * lab2 =(UILabel*)lableArray[1]; lab2.frame =frame1; [lableArray exchangeObjectAtIndex:0 withObjectAtIndex:1]; }]; }