您的位置:首页 > 产品设计 > UI/UE

使用UIView的animation

2015-09-01 14:19 639 查看
#import "ViewController.h"
/**
*  用UIView实现简单的动画效果
*/
@interface ViewController ()
{
UIImageView *myImageV;
}
@end
@implementation ViewController

- (void)viewDidLoad {

myImageV=[[UIImageView alloc]initWithFrame:CGRectMake(100, 44, 100, 100)];
myImageV.image=[UIImage imageNamed:@"Tutorial_p4.png"];
//注意:一定要设置图片视图的这个属性,否则将无法响应点击事件
myImageV.userInteractionEnabled=YES;
[self.view addSubview:myImageV];
UITapGestureRecognizer *tapGR=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(dropAction)];
[myImageV addGestureRecognizer:tapGR];
}

/**
*  图片的点击事件,点击图片将会出现掉落效果
*/
-(void)dropAction{
[UIView animateWithDuration:3.0f animations:^{
//让imageView离开界面时的掉落效果
myImageV.frame=CGRectMake(0, 1000, 100, 100);
NSLog(@"掉落事件");
}];
}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

@end
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: