Magicpang

Tracking the Road

cocos2dx 3.6 webview背景透明(ios android)

- (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="background-color:transparent;"
/cocos2d/cocos/ui/UIWebViewImpl-ios.mm

Android Cocos2dxWebView.java

    public Cocos2dxWebView(Context context, int viewTag) {

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

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

阅读更多
上一篇Xcode7 *** does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_
下一篇Eclipse hangs at the Android SDK Content Loader
想对作者说点什么? 我来说一句

cocos中使用Webview

2017年10月12日 4.77MB 下载

没有更多推荐了,返回首页

关闭
关闭