mirror of
https://github.com/status-im/react-native-transparent-video.git
synced 2025-01-09 22:36:12 +00:00
37 lines
911 B
Swift
37 lines
911 B
Swift
|
@objc(TransparentVideoViewManager)
|
||
|
class TransparentVideoViewManager: RCTViewManager {
|
||
|
|
||
|
override func view() -> (TransparentVideoView) {
|
||
|
return TransparentVideoView()
|
||
|
}
|
||
|
|
||
|
@objc override static func requiresMainQueueSetup() -> Bool {
|
||
|
return false
|
||
|
}
|
||
|
}
|
||
|
|
||
|
class TransparentVideoView : UIView {
|
||
|
|
||
|
@objc var color: String = "" {
|
||
|
didSet {
|
||
|
self.backgroundColor = hexStringToUIColor(hexColor: color)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func hexStringToUIColor(hexColor: String) -> UIColor {
|
||
|
let stringScanner = Scanner(string: hexColor)
|
||
|
|
||
|
if(hexColor.hasPrefix("#")) {
|
||
|
stringScanner.scanLocation = 1
|
||
|
}
|
||
|
var color: UInt32 = 0
|
||
|
stringScanner.scanHexInt32(&color)
|
||
|
|
||
|
let r = CGFloat(Int(color >> 16) & 0x000000FF)
|
||
|
let g = CGFloat(Int(color >> 8) & 0x000000FF)
|
||
|
let b = CGFloat(Int(color) & 0x000000FF)
|
||
|
|
||
|
return UIColor(red: r / 255.0, green: g / 255.0, blue: b / 255.0, alpha: 1)
|
||
|
}
|
||
|
}
|