UIView动画
来源:互联网 发布:大数据应用的调研提纲 编辑:程序博客网 时间:2024/06/05 10:30
IOS动画实现很简单,几行代码就能制作出很漂亮的效果。
实现一个这样的动画:从视图控制器底部创建一个红色区域的视图,并且慢慢上升。
1.创建
_aniView = [[UIView alloc] initWithFrame:CGRectMake(0, self.view.bounds.size.height, self.view.bounds.size.width, 50)]; _aniView.backgroundColor = [UIColor redColor]; _aniView.alpha = 0; [self.view addSubview:_aniView]; [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:1.0]; _aniView.frame = CGRectMake(0, 500, self.view.bounds.size.width,self.view.bounds.size.height-300); _aniView.alpha = 1; [UIView commitAnimations]; _ctrl = [[UIControl alloc] initWithFrame:self.view.bounds]; _ctrl.backgroundColor = [UIColor colorWithRed:200.0f/255.0f green:100.0f/255.0f blue:50/255 alpha:0.5]; [_ctrl addTarget:self action:@selector(showView:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:_ctrl];
2.点击UIControl后,动画消失。
- (void)showView:(UIControl *)ctl{// [UIView beginAnimations:nil context:nil];// [UIView setAnimationDuration:1.0];// showView.frame = CGRectMake(0, self.view.bounds.size.height, self.view.bounds.size.width, 100);// showView.alpha = 0;// [UIView commitAnimations]; [UIView animateWithDuration:1.0 animations:^{ _aniView.frame = CGRectMake(0, self.view.bounds.size.height, self.view.bounds.size.width, self.view.bounds.size.height - 300);// [_aniView removeFromSuperview]; }]; [ctl removeFromSuperview]; }
0 0
- UIView动画
- UIView 动画
- UIView动画
- uiview动画
- UIView动画
- UIView 动画
- UIView动画
- 动画 UIView
- UIView动画
- UIView动画
- uiview 动画
- UIView 动画
- UIView动画
- UIView动画
- UIView动画
- UIView 动画
- UIview动画
- UIView动画
- [leetcode]34 String to Integer (atoi)
- 没啥进展。。
- [省选前题目整理][BZOJ 1022][SHOI 2008]小约翰的游戏John(Anti-SG博弈)
- NSDictionary,NSArray的简写
- 山大工大联谊1008 Integer Division I
- UIView动画
- C#自定义android控件
- Socket网络编程中使用ObjectInputStream与ObjectOutputStream的注意事项
- 在 Android 上通过模拟 HTTP multipart/form-data 请求协议信息实现图片上传
- AngularJS自学之路(一)——初识AngularJS和数据绑定
- const int* pt || int* const pt || const int* const pt 之间的区别
- 无模板使用xmind绘制流程图
- jsp 如何把session.getAttribute()的值转化成int类型
- C/C++ socket编程(2)