从下往上移动UIView
如何在代码中从下到上移动视图:
colorView.hidden=NO; colorView=[[UIView alloc]init]; colorView.frame=CGRectMake(0,480,320, 480); colorView.bounds=CGRectMake(0,200,320, 280); colorView.backgroundColor=[UIColor greenColor]; colorView.alpha=1.0f; [webView addSubview:colorView]; [self.view addSubview:webView]; [self createTransparentView];
那么我如何在这里添加animation呢?
最初,添加您的观点:
self.postStatusView.frame = CGRectMake(0, 490, 320, 460);
对于从下到上的animation添加如下:
[UIView animateWithDuration:0.5 delay:0.1 options: UIViewAnimationOptionCurveEaseIn animations:^{ self.postStatusView.frame = CGRectMake(0, 0, 320, 460); } completion:^(BOOL finished){ }]; [self.view addSubview:self.postStatusView];
去除视图
[UIView animateWithDuration:1.5 delay:0.5 options: UIViewAnimationOptionCurveEaseIn animations:^{ self.postStatusView.frame = CGRectMake(0, 490, 320, 460); } completion:^(BOOL finished){ if (finished) [self.postStatusView removeFromSuperview]; }];
self.colorView.frame = CGRectMake(0, 490, 320, 460); [UIView animateWithDuration:0.5 delay:0.1 options: UIViewAnimationCurveEaseIn animations:^{ self.colorView.frame = CGRectMake(0, 0, 320, 460); } completion:^(BOOL finished){ }]; [self.view addSubview:self.colorView]; [UIView animateWithDuration:1.5 delay:0.5 options: UIViewAnimationCurveEaseIn animations:^{ self.colorView.frame = CGRectMake(0, 490, 320, 460); } completion:^(BOOL finished){ [self.colorView removeFromSuperview]; }];
self.tableView.frame = CGRectMake(0, 490, [[UIScreen mainScreen] bounds].size.width, [[UIScreen mainScreen] bounds].size.height); [UIView animateWithDuration:.35 delay:0.0 options: UIViewAnimationOptionCurveEaseInOut animations:^{ self.tableView.frame = CGRectMake(0, -20, [[UIScreen mainScreen] bounds].size.width, [[UIScreen mainScreen] bounds].size.height); } completion:^(BOOL finished){ [UIView animateWithDuration:0.1 delay:0.0 options: UIViewAnimationOptionCurveEaseInOut animations:^{ self.tableView.frame = CGRectMake(0, 20, [[UIScreen mainScreen] bounds].size.width , [[UIScreen mainScreen] bounds].size.height); } completion:^(BOOL finished){ [UIView animateWithDuration:0.1 delay:0.0 options: UIViewAnimationOptionCurveEaseInOut animations:^{ self.tableView.frame = CGRectMake(0, 0, [[UIScreen mainScreen] bounds].size.width, [[UIScreen mainScreen] bounds].size.height); } completion:^(BOOL finished){ }]; }]; }];
- 用BOOL /完成块停止自动反向/无限重复UIViewanimation
- 停止使用RepeatsForever – Sprite Kit的SKAction
- 以自定义模式呈现UINavigationController
- 多次旋转图像并停止在所需的程度?
- Swift – 何时或如何在视图上实现animation开始?
- 在UIPresentationController中animation呈现视图
- 我怎么能在viewDidLoad做UIView animateWithDuration? IOS 7
- 协调CACurrentMediaTime()和deviceCurrentTime
- 可拖动的UIView Swift 3