How to convert `UIColor` to SwiftUI‘s `Color`

nOk picture nOk · Jul 11, 2019 · Viewed 13.3k times · Source

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))

Answer

kontiki picture kontiki · Jul 30, 2019

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

Color(UIColor.systemBlue)