UIWebView下透明UINavigationBar [英] UIWebView under transparent UINavigationBar

查看:97
本文介绍了UIWebView下透明UINavigationBar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个UIWebView,我想放在我的半透明UINavigationBar。通常,当我把一个UIScrollView在一个半透明的UINavigationBar,我设置它的contentOffset,所有的内容将最初被推后的酒吧,使其可以看到;

I have a UIWebView which I want to put under my translucent UINavigationBar. Normally when I put a UIScrollView under a translucent UINavigationBar, I set its contentOffset such that all content will be initially pushed after the bar so that it can be seen; thereafter, the user can scroll text and it will underlap the bar.

问题是UIWebView似乎不是UIScrollView的一个合适的子类;因此,我不能使用setContentOffset。有没有人有任何提示或技巧获得一个透明的导航栏UIWebView看起来不错?谢谢。

The problem is that UIWebView appears not to be a proper subclass of UIScrollView; thus, I can't use setContentOffset. Does anyone have any tips or tricks on getting a UIWebView to look good with a translucent navigation bar? Thanks.

推荐答案

我不知道是否有一个干净的方法。我没有尝试,但这里是一个想法:

I am not sure if there is a clean method to doing this. I have not tried it, but here is an idea:


  1. 在起点0,0绘制uiwebview

  2. 拦截所有屏幕触摸

  3. 如果您检测到用户向上拖动(向上滚动网页视图),则不要传递

  4. 将webview向上移动x个像素,因此其起点为(0,-x)。然后更改高度以添加x个像素

  5. 您将需要保持某种状态,以便您知道何时停止调整Web视图大小并开始传递触摸,以便Web视图滚动。

  1. draw the uiwebview at origin 0,0
  2. intercept all screen touches
  3. if you detect the user dragging up (scrolling up the webview), dont pass the touch on
  4. Instead, move the webview up x pixels so its origin is (0,-x). Then change the height to add x pixels
  5. Youy will need to keep some sort of state so that you know when to stop resizing the webview and start passing on the touches so the webview will scroll.

只有在向下拖动(向下滚动网页视图)时,才能恢复它。

Getting it back is the same only you do it on a drag down (scrolling down the webview).

这篇关于UIWebView下透明UINavigationBar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆