美文网首页
cordova-plugin-themeablebrowser

cordova-plugin-themeablebrowser

作者: IT姑凉 | 来源:发表于2019-11-27 22:43 被阅读0次

    1、IOS 头部内容被遮挡

    - (void) rePositionViews {
        // Webview height is a bug that appear in the plugin for ios >= 11 so we need to keep the previous code that work great for previous versions
        if (@available(iOS 11, *)) {
            
            CGFloat toolbarHeight = [self getFloatFromDict:_browserOptions.toolbar withKey:kThemeableBrowserPropHeight withDefault:TOOLBAR_DEF_HEIGHT];
            CGFloat statusBarOffset = [self getStatusBarOffset];
            CGFloat webviewOffset = _browserOptions.fullscreen ? 0.0 : toolbarHeight + statusBarOffset;
            
            if ([_browserOptions.toolbarposition isEqualToString:kThemeableBrowserToolbarBarPositionTop]) {
                // The webview height calculated did not take the status bar into account. Thus we need to remove status bar height to the webview height.
                [self.webView setFrame:CGRectMake(self.webView.frame.origin.x, webviewOffset, self.webView.frame.size.width, (self.webView.frame.size.height-statusBarOffset))];
                [self.toolbar setFrame:CGRectMake(self.toolbar.frame.origin.x, [self getStatusBarOffset], self.toolbar.frame.size.width, self.toolbar.frame.size.height)];
            }
            // When positionning the iphone to landscape mode, status bar is hidden. The problem is that we set the webview height just before with removing the status bar height. We need to adjust the phenomen by adding the preview status bar height. We had to add manually 20 (pixel) because in landscape mode, the status bar height is equal to 0.
            if (statusBarOffset == 0) {
                [self.webView setFrame:CGRectMake(self.webView.frame.origin.x, webviewOffset, self.webView.frame.size.width, (self.webView.frame.size.height+20))];
            }
            
            CGFloat screenWidth = CGRectGetWidth(self.view.frame);
            NSInteger width = floorf(screenWidth - self.titleOffset * 2.0f);
            if (self.titleLabel) {
                self.titleLabel.frame = CGRectMake(floorf((screenWidth - width) / 2.0f), 0, width, toolbarHeight);
            }
            
            [self layoutButtons];
            
        } else {
            
            CGFloat toolbarHeight = [self getFloatFromDict:_browserOptions.toolbar withKey:kThemeableBrowserPropHeight withDefault:TOOLBAR_DEF_HEIGHT];
            CGFloat webviewOffset = _browserOptions.fullscreen ? 0.0 : toolbarHeight;
            
            if ([_browserOptions.toolbarposition isEqualToString:kThemeableBrowserToolbarBarPositionTop]) {
                [self.webView setFrame:CGRectMake(self.webView.frame.origin.x, webviewOffset, self.webView.frame.size.width, self.webView.frame.size.height)];
                [self.toolbar setFrame:CGRectMake(self.toolbar.frame.origin.x, [self getStatusBarOffset], self.toolbar.frame.size.width, self.toolbar.frame.size.height)];
            }
            
            CGFloat screenWidth = CGRectGetWidth(self.view.frame);
            NSInteger width = floorf(screenWidth - self.titleOffset * 2.0f);
            if (self.titleLabel) {
                self.titleLabel.frame = CGRectMake(floorf((screenWidth - width) / 2.0f), 0, width, toolbarHeight);
            }
            
            [self layoutButtons];
        }
    }
    

    参考:
    https://github.com/initialxy/cordova-plugin-themeablebrowser/issues/163
    https://github.com/initialxy/cordova-plugin-themeablebrowser/issues/168

    2、全面屏手机没有全屏
    https://github.com/initialxy/cordova-plugin-themeablebrowser/issues/199

    相关文章

      网友评论

          本文标题:cordova-plugin-themeablebrowser

          本文链接:https://www.haomeiwen.com/subject/acapwctx.html