My goal is to understand and implement feature via Core Animation.
I think it\'s not so hard,but unfortunately i don\'t know swift/Obj C and it\'s hard to understand native
I have also faced the issue like https://i.stack.imgur.com/fuVhy.gif commented https://stackoverflow.com/users/4793465/xtl for the above solution.
Am using the view at the bottom of web-view to show and hide like safari mobile browser.
attached the sample code below
UIView *viewV;
UILabel *label;
and viewdidload
-(void)viewDidLoad {
[super viewDidLoad];
WKWebViewConfiguration *theConfiguration = [[WKWebViewConfiguration alloc] init];
WKWebView *webView = [[WKWebView alloc] initWithFrame:self.view.frame configuration:theConfiguration];
webView.navigationDelegate = self;
webView.UIDelegate = self;
webView.scrollView.delegate = self;
NSURL *nsurl=[NSURL URLWithString:@"https://www.google.com/"];
NSURLRequest *nsrequest=[NSURLRequest requestWithURL:nsurl];
[webView loadRequest:nsrequest];
[self.view addSubview:webView];
viewV = [[UIView alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height - 50, self.view.frame.size.width, 50)];
viewV.backgroundColor = [UIColor blueColor];
[webView addSubview:viewV];}
and scroll view delegate
-(void)scrollViewDidScroll:(UIScrollView *)scrollView {
CGPoint velocity = [[scrollView panGestureRecognizer] velocityInView:scrollView.superview];
if (velocity.y == 0) {
return;
}
if (velocity.y < -1) {
// Scrolling left
NSLog(@"Top");
if (viewV.frame.origin.y != self.view.frame.size.height - 50) {// if already hidden, don't need to hide again
return;
}
[UIView animateWithDuration:0.2 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
viewV.backgroundColor = [UIColor clearColor];
viewV.frame = CGRectMake(0, viewV.frame.origin.y + 50, self.view.frame.size.width, 0);
} completion:^(BOOL finished) {
}];
} else if (velocity.y > 1) {
// Scrolling Right
NSLog(@"Bottom");
if (viewV.frame.origin.y != self.view.frame.size.height) { // if already shown, no need to do show again
return;
}
[UIView animateWithDuration:0.2 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
viewV.backgroundColor = [UIColor blueColor];
viewV.frame = CGRectMake(0, viewV.frame.origin.y - 50, self.view.frame.size.width, 50);
} completion:^(BOOL finished) {
}];
}}
This worked for me.