title: Use Hex color in SwiftUI
body: <p>In UIKit we could use an Extension to set hex color to almost everything, like in this <a href="https://www.hackingwithswift.com/example-code/uicolor/how-to-convert-a-hex-color-to-a-uicolor" rel="noreferrer">tutorial</a>. But when I'm trying to do it in SwiftUI, it's not possible, it looks like the SwiftUI does not get the <code>UIColor</code> as parameter.</p>
  <pre><code>Text(text)
      .color(UIColor.init(hex: &quot;FFF&quot;))
  </code></pre>
  <p>Error message:</p>
  <pre class="lang-none prettyprint-override"><code>Cannot convert value of type 'UIColor' to expected argument type 'Color?'
  </code></pre>
  <p>I even tried to make an extension for <code>Color</code>, instead of <code>UIColor</code>, but I haven't any luck.</p>
  <p>My extension for <code>Color</code>:</p>
  <pre><code>import SwiftUI
  
  extension Color {
      init(hex: String) {
          let scanner = Scanner(string: hex)
          scanner.scanLocation = 0
          var rgbValue: UInt64 = 0
          scanner.scanHexInt64(&amp;rgbValue)
          
          let r = (rgbValue &amp; 0xff0000) &gt;&gt; 16
          let g = (rgbValue &amp; 0xff00) &gt;&gt; 8
          let b = rgbValue &amp; 0xff
          
          self.init(
              red: CGFloat(r) / 0xff,
              green: CGFloat(g) / 0xff,
              blue: CGFloat(b) / 0xff, alpha: 1
          )
      }
  }
  </code></pre>
  <p>Error message:</p>
  <pre class="lang-none prettyprint-override"><code>Incorrect argument labels in call (have 'red:green:blue:alpha:', expected '_:red:green:blue:opacity:')
  </code></pre>