반응형 hexstring1 [Swift/UIKit] UIColor를 HexString으로 받는 Extension extension UIColor { convenience init(hexString: String) { let hex = hexString.trimmingCharacters(in: CharacterSet.alphanumerics.inverted) var int = UInt64() Scanner(string: hex).scanHexInt64(&int) let alpha, red, green, blue: UInt64 switch hex.count { case 3: (alpha, red, green, blue) = (255, (int >> 8) * 17, (int >> 4 & 0xF) * 17, (int & 0.. 2024. 7. 19. 이전 1 다음 반응형