Mobile-UXSDK-Beta-iOS icon indicating copy to clipboard operation
Mobile-UXSDK-Beta-iOS copied to clipboard

How can I change DUXBetaFPVWidget.fpvView.backgroundColor

Open fanbaoyuanbees360 opened this issue 3 years ago • 1 comments

I want to change fpvWidget.fpvView.backgroundColor, but the fpvView is fileprivate.

How can I change the fpvView.backgroundColor?

fanbaoyuanbees360 avatar Jul 08 '21 08:07 fanbaoyuanbees360

I know my solution is already late for you but I am pretty sure it is helpful for others!

The way that you change the background color of the FPVWidget is as follows:

// Define FPV Widget  instance
let fpvWidget = DUXBetaFPVWidget()
// Access its view
let fpvWidgetView = fpvWidget.view
// Adding its view to current ViewController views (Important Step)
view.addSubview(fpvWidgetView!)

// Access all subviews inside the fpvWidgetView
fpvWidgetView!.subviews.forEach { v in
    if v.duxbeta_className() == "UIView" { // This is exactly the view that we are changing  its color to green
        v.backgroundColor = .green
    }
    print(v.duxbeta_className()) // See all other subviews types 
    //[UIView, UXSDKCore.DUXBetaFPVGridView, UXSDKCore.DUXBetaFPVCenterView, UIStackView] will be printed out!
}

// stretch the fpvWidget to the whole screen
fpvWidgetView!.translatesAutoresizingMaskIntoConstraints = true
fpvWidget.install(in: self)

photo_2022-05-08 18 04 31

alzin avatar May 08 '22 09:05 alzin