首页 > 代码库 > Webview背景设置透明(ios android)

Webview背景设置透明(ios android)

http://blog.csdn.net/magicpang/article/details/50014373

先复制过来备份,暂时未测试

 

- (void)setupWebView {
    if (!self.uiWebView) {
        self.uiWebView = [[[UIWebView alloc] init] autorelease];
        self.uiWebView.delegate = self;
    }
    if (!self.uiWebView.superview) {
        auto view = cocos2d::Director::getInstance()->getOpenGLView();
        auto eaglview = (CCEAGLView *) view->getEAGLView();
        [eaglview addSubview:self.uiWebView];
    }
}
- (void)setupWebView {
    if (!self.uiWebView) {
        self.uiWebView = [[[UIWebView alloc] init] autorelease];
        self.uiWebView.delegate = self;
        
        // 15/7/17 add
        [self.uiWebView setOpaque:NO];
        [self.uiWebView setBackgroundColor:[UIColor clearColor]];
    }
    if (!self.uiWebView.superview) {
        auto view = cocos2d::Director::getInstance()->getOpenGLView();
        auto eaglview = (CCEAGLView *) view->getEAGLView();
        [eaglview addSubview:self.uiWebView];
    }
}
style=""
/cocos2d/cocos/ui/UIWebViewImpl-ios.mm

Android Cocos2dxWebView.Java

    public Cocos2dxWebView(Context context, int viewTag) {

        this.setBackgroundColor(0); // 设置背景色  

        //this.getBackground().setAlpha(0); // 设置填充透明度 范围:0-255

Webview背景设置透明(ios android)