Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)) 
like image 275
nOk Avatar asked Jul 11 '19 17:07

nOk


People also ask

How do you convert Heicolor to hex?

To convert a UIColor instance to a hex value, we define a convenience method, toHex(alpha:) . The method accepts one parameter of type Bool , which indicates whether the alpha value should be included in the string that is returned from the method.


1 Answers

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

Color(UIColor.systemBlue) 
like image 121
kontiki Avatar answered Oct 05 '22 01:10

kontiki