Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

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
Comment

swift ui color rgb

let exampleColor : Color = Color(red: 141/255, green: 223/255, blue: 144/255)
Comment

PREVIOUS NEXT
Code Example
Swift :: Swift Function overloading with Argument Label 
Swift :: Rules for naming Swift Variables 
Swift :: swift multiline comment 
Swift :: swift converting time string to number 
Swift :: swift get error from the from completion 
Swift :: array of button listeners swift 
Swift :: Swift Arithmetic Operators 
Swift :: Swift Nested Tuple 
Swift :: Swift Find Number of Dictionary Elements 
Swift :: swift api call certificate 
Swift :: swift_SmtpTransport with oauth2 
Swift :: add placeholder to code snippets xcode 
Swift :: how to read music library from iphone programmatically in swift 
Swift :: secure password field in textfield swift 
Swift :: Swift print() with terminator 
Swift :: ios network request 
Swift :: circular array swift 
Ruby :: base64 decode ruby 
Ruby :: rails activestorage get image url 
Ruby :: array ruby taking 3 last value 
Ruby :: ruby delete folder recursively 
Ruby :: unix timestamp to date time rails 
Ruby :: ruby case when multiple conditions 
Ruby :: ruby substring remove 
Ruby :: rails resources only 
Ruby :: form feild rails helper 
Ruby :: link to do rails 
Ruby :: rails cors allow all 
Ruby :: rspec gem tutorial 
Ruby :: all rails g model types 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =