Answers for "uicolor to swiftui color"

1

uicolor from hex swift

extension UIColor {
    convenience init(hexaString: String, alpha: CGFloat = 1) {
        let chars = Array(hexaString.dropFirst())
        self.init(red:   .init(strtoul(String(chars[0...1]),nil,16))/255,
                  green: .init(strtoul(String(chars[2...3]),nil,16))/255,
                  blue:  .init(strtoul(String(chars[4...5]),nil,16))/255,
                  alpha: alpha)}
}
let redColor       = UIColor(hexaString: "#FF0000")              // r 1,0 g 0,0 b 0,0 a 1,0
let transparentRed = UIColor(hexaString: "#FF0000", alpha: 0.5)  // r 1,0 g 0,0 b 0,0 a 0,5
Posted by: Guest on February-03-2021
0

swift set uicolor

let swiftColor = UIColor(red: 1, green: 165/255, blue: 0, alpha: 1)
Posted by: Guest on June-08-2020

Code answers related to "Swift"

Browse Popular Code Answers by Language