Reputation: 1481
I am following the suggestions of some posts to make a webview transparent, but it still is opaque and white. This code is from a plugin for unity3d that adds a webview in unity. Is there something about this code that would cause it not to be transparent?
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;
}
Upvotes: 1
Views: 911
Reputation: 14009
I'm the author of the plugin, and it should work well as far as I know.
Have you tried more simple HTML like this?
<body style="background-color: transparent;">
Upvotes: 1