透明的webview在ios中不起作用

时间:2014-12-18 19:40:50

标签: ios webview transparent

我遵循一些帖子的建议,使网页视图透明,但它仍然是不透明和白色的。此代码来自unity3d的插件,它可以统一添加webview。这段代码有什么东西会导致它不透明吗?

https://github.com/gree/unity-webview

 #import <UIKit/UIKit.h>
    extern UIView *UnityGetGLView();

    extern UIViewController *UnityGetGLViewController();
    extern "C" void UnitySendMessage(const char *, const char *, const char *);
    extern UIWindow *_window;

    @interface WebViewPlugin : NSObject<UIWebViewDelegate>
    {
        UIWebView *webView;
        NSString *gameObjectName;
    }
    @end

    @implementation WebViewPlugin

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
     return YES;
    } 

    - (id)initWithGameObjectName:(const char *)gameObjectName_
    {
    self = [super init];

        UIView *view = UnityGetGLViewController().view;
        webView = [[UIWebView alloc] initWithFrame:view.frame];
        webView.delegate = self;
        webView.hidden = YES;
        webView.scrollView.scrollEnabled = NO; 
        [webView setBackgroundColor:[UIColor clearColor]];
        [webView setOpaque:NO];
        [view addSubview:webView];
        gameObjectName = [[NSString stringWithUTF8String:gameObjectName_] retain];

        return self;    
    }

HTML / CSS

html, body {
  height: 100%;
  width:100%;
  font-size:12px;
//background: rgba(255, 255, 255, 0);
background-color: transparent;
}   

1 个答案:

答案 0 :(得分:1)

我是该插件的作者,据我所知它应该可以正常工作。

您是否尝试过更简单的HTML?

<body style="background-color: transparent;">