[ios] How can I create a UIColor from a hex string?

Use Xcode's native Color Literals feature to add hex colors easily and natively.

Type Color Literal into your code and let Xcode autocomplete do the rest.

The color picker UI will allow you to paste in a Hex Color: #FF9300

color picker

The git diff of the macro will show RGB values rather than hex:

let orange = #colorLiteral(red: 1, green: 0.5763723254, blue: 0, alpha: 1)

But it's still an easy way to paste in hex without any 3rd party tools or extensions.

Examples related to ios

Adding a UISegmentedControl to UITableView Crop image to specified size and picture location Undefined Symbols error when integrating Apptentive iOS SDK via Cocoapods Keep placeholder text in UITextField on input in IOS Accessing AppDelegate from framework? Autoresize View When SubViews are Added Warp \ bend effect on a UIView? Speech input for visually impaired users without the need to tap the screen make UITableViewCell selectable only while editing Xcode 12, building for iOS Simulator, but linking in object file built for iOS, for architecture arm64

Examples related to cocoa-touch

Include of non-modular header inside framework module Move textfield when keyboard appears swift Create space at the beginning of a UITextField Navigation bar with UIImage for title Generate a UUID on iOS from Swift How do I write a custom init for a UIView subclass in Swift? creating custom tableview cells in swift How would I create a UIAlertView in Swift? Get current NSDate in timestamp format How do you add an in-app purchase to an iOS application?

Examples related to uicolor

How to use hex color values Programmatically create a UIView with color gradient How can I change image tintColor in iOS and WatchKit How to change the status bar background color and text color on iOS 7? How can I get the iOS 7 default blue color programmatically? Making RGB color in Xcode Can not change UILabel text color How can I create a UIColor from a hex string?