Search code examples
swiftcolorsuicolorswiftui

How to convert UIColor to SwiftUI‘s Color


I want to use a UIColor as foregroundcolor for an object but I don’t know how to convert UIColor to a Color

var myColor: UIColor
RoundedRectangle(cornerRadius: 5).foregroundColor(UIColor(myColor))

Solution

  • Starting with beta 5, you can create a Color from a UIColor:

    Color(UIColor.systemBlue)