#import "ViewController.h"
#define kScreenW [UIScreen mainScreen].bounds.size.width
#define kScreenH [UIScreen mainScreen].bounds.size.height
#define toolH 88
@interface ViewController ()
@property (nonatomic, strong) UIView *topView;
@property (nonatomic, strong) UIView *bottomView;
@property (nonatomic, assign) BOOL toolViewShow;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor lightGrayColor];
[self.view addSubview:self.topView];
[self.view addSubview:self.bottomView];
self.toolViewShow = NO;
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
if(self.toolViewShow) {
[UIView animateWithDuration:0.25 animations:^{
self.topView.frame = CGRectMake(0, -(toolH), kScreenW, toolH);
self.bottomView.frame = CGRectMake(0, kScreenH, kScreenW, toolH);
} completion:^(BOOL finished) {
self.topView.hidden = YES;
self.bottomView.hidden = YES;
}];
} else {
self.topView.hidden = NO;
self.bottomView.hidden = NO;
[UIView animateWithDuration:0.25 animations:^{
self.topView.frame = CGRectMake(0, 0, kScreenW, toolH);
self.bottomView.frame = CGRectMake(0, kScreenH-toolH, kScreenW, toolH);
}];
}
self.toolViewShow = !self.toolViewShow;
}
- (UIView *)topView {
if(_topView == nil) {
_topView = [[UIView alloc]initWithFrame:CGRectMake(0, -(toolH), kScreenW, toolH)];
_topView.hidden = YES;
_topView.backgroundColor = [UIColor orangeColor];
}
return _topView;
}
- (UIView *)bottomView {
if(_bottomView == nil) {
_bottomView = [[UIView alloc]initWithFrame:CGRectMake(0, kScreenH, kScreenW, toolH)];
_bottomView.hidden = YES;
_bottomView.backgroundColor = [UIColor redColor];
}
return _bottomView;
}
@end