title: Is there a more elegant way to use Color Literals in SwiftUI?
body: <p><strong>Edit</strong>: It isn't recommended to use <code>Color Literal</code> in SwiftUI. Rather, it's proper to use color assets. However, this question comes out of curiosity.</p>
  <p>Swift's <code>Color Literal</code> provides a visual way to get colors within your code.</p>
  <p>With SwiftUI, a <code>Color</code> instance can be defined from a <code>Color Literal</code> using the <code>Color(_ color: UIColor)</code> initializer, like so:</p>
  <p><a href="https://i.stack.imgur.com/yzrEg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yzrEg.png" alt="Image 1" /></a></p>
  <p>However, attempting to create a <code>Color</code> instance without this initializer gives an error:</p>
  <p><a href="https://i.stack.imgur.com/p4bhY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/p4bhY.png" alt="enter image description here" /></a></p>
  <pre><code>Error: Cannot convert value of type 'UIColor' to specified type 'Color'
  </code></pre>
  <p>Is there any workaround where I can create a <code>Color</code> instance from just a <code>Color Literal</code> without having to use the <code>Color(_ color: UIColor)</code> initializer?</p>
  <p>Here is the closest I could get to a solution, using an extension of <code>UIColor</code>:</p>
  <pre class="lang-swift prettyprint-override"><code>extension UIColor {
    
    /// Gets a `Color` instance
    var c: Color {
      Color(self)
    }
  }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/yTtzl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yTtzl.png" alt="enter image description here" /></a></p>
  <p>Please note that this question is merely for code elegance, and that the trivial solution would be to use the initializer.</p>