This is a HEX to UIColor converter for Swift. #2563EB is UIColor(red: 0.145, green: 0.388, blue: 0.922, alpha: 1.000). Also SwiftUI, NSColor and Objective-C.
Examples — click a swatch
Click a value to copy it
Convert several colors at once. One per line, or commas such as #3B82F6, #FF573380. Fill example loads three rows and the table below.
This is a HEX to UIColor converter for Swift and UIKit. Channels are floats from 0 to 1, not 0–255. #2563EB is UIColor(red: 0.145, green: 0.388, blue: 0.922, alpha: 1.000). The same page prints SwiftUI, NSColor and Objective-C. HEX to RGBA is the CSS form of those channels.
Each channel is byte / 255, then three decimals: 37/255 → 0.145, 99/255 → 0.388, 235/255 → 0.922. Alpha is 1.000 for 6-digit HEX; 8-digit HEX uses the last two bytes (80 hex ≈ 0.502). UIColor /255 keeps the integers so you can see 37/255 next to 0.145. Invalid HEX shows an error instead of crashing. Related: HEX to RGBA, Color Converter.
UIColor(red:green:blue:alpha:) takes floats. Passing 37, 99, 235 looks washed out or wrong. Use the /255 line if you prefer integers in source.
Six-digit HEX is 1.000. Eight-digit HEX8, such as #2563EB80, sets alpha from the last byte.
Yes for UI. 0.145 vs 37/255 is not a visible shift on a screen.