下面是設置:如何在連接到UIWebView的導航欄上實現模糊的半透明效果?
- 背景圖像。
- 導航欄。
- 一個UIWebView。
我想要的導航欄獲取基礎上的UIWebView的內容模糊半透明的效果但這樣做的依據的背景圖像模糊。我該如何解決它?
如何將導航欄連接到UIWebView,以便在用戶向下滾動時模糊效果發生變化並正確顯示?
這裏有一個想法,我有實際工作:
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[self setAutomaticallyAdjustsScrollViewInsets:YES];
self.webView = [[WKWebView alloc] init];
self.webView.frame = CGRectMake(0, 44, self.view.frame.size.width, self.view.frame.size.height);
self.webView.scrollView.delegate = self;
[self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.insomnia.gr"]]];
UINavigationBar *navigationBar = [[UINavigationBar alloc] init];
navigationBar.frame = CGRectMake(0, 0, self.view.frame.size.width, 44);
navigationBar.tintColor = [UIColor clearColor];
navigationBar.translucent = YES;
[self.view addSubview:self.webView];
[self.view addSubview:navigationBar];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark -
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
NSLog(@"WebView - Location Y: %f Height: %f", self.webView.frame.origin.y, self.webView.frame.size.height);
if (scrollView.contentOffset.y >= 44) {
// Scale to maximum size.
self.webView.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
}
else if (scrollView.contentOffset.y > 0) {
// Scale relative to content offset.
self.webView.frame = CGRectMake(0, 44 - scrollView.contentOffset.y, self.view.frame.size.width, self.view.frame.size.height + scrollView.contentOffset.y);
}
else {
// Scale to original.
self.webView.frame = CGRectMake(0, 44, self.view.frame.size.width, self.view.frame.size.height - 44);
}
}
但是,它甚至還沒有接近一個優雅和簡單的解決方案。
你一定是在開玩笑吧?這是一個非常嚴重的UI問題,我實際上發佈了一個解決方案,我得到-1? – Vulkan 2014-11-15 13:51:42