// // ViewController.h // 01-anniu // // Created by kevin on 13-11-22. // Copyright (c) 2013年 kevin. All rights reserved. // #import <UIKit/UIKit.h> @interface ViewController : UIViewController @property (weak, nonatomic) IBOutlet UIButton *btn; - (IBAction)up:(id)sender; - (IBAction)right:(id)sender; - (IBAction)down:(id)sender; - (IBAction)left:(id)sender; @end
#import "ViewController.h"@interface ViewController () @end @implementation ViewController - (IBAction)up:(id)sender { //设置动画和功能以及时间长短 [UIView beginAnimations:Nil context:nil]; [UIView setAnimationDuration:1.0]; // 先取出frame CGRect tempfram = _btn.frame; // 再修改y值 tempfram.origin.y = tempfram.origin.y - 50; // 重新赋值给按钮的frame _btn.frame = tempfram; [UIView commitAnimations]; }
按钮的animation移动
最新推荐文章于 2021-04-01 14:00:28 发布