使用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
相关文章推荐
- UINavigationController 弹出新的UIViewController时,setNavigationBarHidden失效的问题
- ios uitableview 去掉多余的空行
- ios uitableview uitableviewcell 去掉分隔线
- iPad开发,UIPopoverController的使用
- 关于开源框架GPUImage 的简单说明
- HDU——1242 Rescue(广搜)
- NewBluePill源码学习 <一>
- java.lang.NoClassDefFoundError: com.nostra13.universalimageloader.core.DisplayImageOptions$Builder
- UISearchBar
- AutoLabelUI 点击列表每一个item动态添加标签
- HDU 1711 Number Sequence(KMP模板)
- Leetcode: Distinct Subsequences
- Angular-UI自动完成输入框AutoComplete[项目中使用]
- 1051. Pop Sequence (25)
- UE3 距离场阴影
- UI中随机数的操作
- 调试MSBuild脚本
- EasyUi 合并单元格占列显示
- 一个变量在uefi中的传递过程
- [Bluetooth Core V4.2] VOL2, PartB, 6 Packets