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

ios UIimageView 手势移动动画效果

2013-09-30 14:21 357 查看
在Viewdidload中初始化:

定义一个bool型的open属性

//--------左边的 图片;
self.leftimg=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"left"]];
self.leftimg.frame=CGRectMake(0, 512, 20, 30);
self.leftimg.userInteractionEnabled=YES;//可交互的
//添加手势
UITapGestureRecognizer *TapGesture=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(move)];
[self.leftimg addGestureRecognizer:TapGesture];
[self.view addSubview:self.leftimg];
[self.leftimg release];


然后出发move方法

-(void)move
{

if (_open) {
[UIView animateWithDuration:0.2 animations:^{

[self.leftimg setFrame:CGRectMake(0, 512, 20, 30)];
[self.VideoTab setFrame:CGRectMake(-200, 50, 200,850)];

self.leftimg.image=[UIImage imageNamed:@"left"];
}];
_open=false;
}
else
{
[UIView animateWithDuration:0.2 animations:^{
self.leftimg.image=[UIImage imageNamed:@"right"];
[self.leftimg setFrame:CGRectMake(200, 512, 20, 30)];
[self.VideoTab setFrame:CGRectMake(0, 50, 200,850)];
_open=true;
}];
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐