【问题标题】:CameraPreview is not showing when toBack is true当 toBack 为真时,CameraPreview 不显示
【发布时间】:2018-01-18 19:24:38
【问题描述】:

在我的 Ionic 应用程序中,我有一个模态视图。我希望它的背景是一个 CameraPreview 块,但是当我将 toBack 属性设置为 true 时它不起作用。

这是我的相机选项:

public cameraPreviewOpts: CameraPreviewOptions = {
 x: 0,
 y: 0,
 width: window.screen.width,
 height: 300,
 camera: 'rear',
 tapPhoto: true,
 previewDrag: false,
 toBack: true,
 alpha: 1
};

当我将 toBack 设置为 false 时,cameraPreview 工作正常,但我想访问我的导航栏和预览上方的一些按钮,所以我需要在这里找到什么不起作用。

如果需要,我很乐意为您提供更多信息。 谢谢!

【问题讨论】:

    标签: ionic-framework cordova-plugins ionic3 ionic-native


    【解决方案1】:

    您确定它没有隐藏在另一个 HTML 元素后面吗?

    你试过设置背景色吗?

    html, body, .ion-app, .ion-content { background-color: transparent; }

    【讨论】:

      【解决方案2】:

      将此添加到您正在使用相机的页面的构造函数中。

      document.body.style.backgroundColor = "transparent !important"
      

      我在 variables.scss 以及我尝试应用的所有地方都使用了深色/浅色主题模式

      html, body, .ion-app, .ion-content {
        background-color: transparent;
      }
      

      <ion-content [fullscreen]="true" [ngClass]="{'custom-ion-content': true}"> 
      
      .custom-ion-content {   
         --background-color: transparent !important;   
      }
      

      根本没用。这为我解决了。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-05-29
        • 2014-09-11
        • 2018-10-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-03-01
        相关资源
        最近更新 更多