diff --git a/AppleLibs.xcodeproj/project.pbxproj b/AppleLibs.xcodeproj/project.pbxproj index 963b18d61d497d08f630bb3f770f4a6c27d2aae2..6da0fc9a62322a31de6c901fe9e08ef6b7d9edcf 100644 --- a/AppleLibs.xcodeproj/project.pbxproj +++ b/AppleLibs.xcodeproj/project.pbxproj @@ -15,6 +15,7 @@ F623A6742635B5BE00F50371 /* Enum+Extended.swift in Sources */ = {isa = PBXBuildFile; fileRef = F623A6732635B5BE00F50371 /* Enum+Extended.swift */; }; F623A67B2635B5F900F50371 /* Date+Styled.swift in Sources */ = {isa = PBXBuildFile; fileRef = F623A67A2635B5F900F50371 /* Date+Styled.swift */; }; F62B93A7261A492700D7F8E6 /* String+Size.swift in Sources */ = {isa = PBXBuildFile; fileRef = F62B93A6261A492700D7F8E6 /* String+Size.swift */; }; + F6450F6D26A0CEA200076347 /* UIColor+Hex.swift in Sources */ = {isa = PBXBuildFile; fileRef = F6450F6C26A0CEA200076347 /* UIColor+Hex.swift */; }; F673A9942635EF510017AD37 /* DataManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = F673A98E2635EF510017AD37 /* DataManager.swift */; }; F673A9952635EF510017AD37 /* HttpStatusCode.swift in Sources */ = {isa = PBXBuildFile; fileRef = F673A98F2635EF510017AD37 /* HttpStatusCode.swift */; }; F673A9962635EF510017AD37 /* ResponseError.swift in Sources */ = {isa = PBXBuildFile; fileRef = F673A9902635EF510017AD37 /* ResponseError.swift */; }; @@ -50,6 +51,7 @@ F623A6732635B5BE00F50371 /* Enum+Extended.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Enum+Extended.swift"; sourceTree = "<group>"; }; F623A67A2635B5F900F50371 /* Date+Styled.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Date+Styled.swift"; sourceTree = "<group>"; }; F62B93A6261A492700D7F8E6 /* String+Size.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+Size.swift"; sourceTree = "<group>"; }; + F6450F6C26A0CEA200076347 /* UIColor+Hex.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIColor+Hex.swift"; sourceTree = "<group>"; }; F673A98E2635EF510017AD37 /* DataManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DataManager.swift; sourceTree = "<group>"; }; F673A98F2635EF510017AD37 /* HttpStatusCode.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HttpStatusCode.swift; sourceTree = "<group>"; }; F673A9902635EF510017AD37 /* ResponseError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ResponseError.swift; sourceTree = "<group>"; }; @@ -146,6 +148,7 @@ isa = PBXGroup; children = ( F68BFE6A263B28B000E893E5 /* UIViewController+Screenshot.swift */, + F6450F6C26A0CEA200076347 /* UIColor+Hex.swift */, ); path = View; sourceTree = "<group>"; @@ -337,6 +340,7 @@ F623A66C2635B57500F50371 /* NumberFormatter.swift in Sources */, F6A251BE260B699100132DEC /* String+Html.swift in Sources */, F673A9952635EF510017AD37 /* HttpStatusCode.swift in Sources */, + F6450F6D26A0CEA200076347 /* UIColor+Hex.swift in Sources */, F673A9982635EF510017AD37 /* ResponseHandler.swift in Sources */, F623A6742635B5BE00F50371 /* Enum+Extended.swift in Sources */, F673A9962635EF510017AD37 /* ResponseError.swift in Sources */, diff --git a/AppleLibs/View/UIColor+Hex.swift b/AppleLibs/View/UIColor+Hex.swift new file mode 100644 index 0000000000000000000000000000000000000000..137be03b699fdea228305a0112f8df7542b32094 --- /dev/null +++ b/AppleLibs/View/UIColor+Hex.swift @@ -0,0 +1,20 @@ +// +// UIColor+Hex.swift +// AppleLibs +// +// Created by Tobias on 15.07.21. +// + +import UIKit + +extension UIColor { + convenience init(hexString: String, alpha: CGFloat = 1) { + self.init(hex: UInt(hexString.hasPrefix("#") ? String(hexString.dropFirst()) : hexString, radix: 16) ?? 0, alpha: alpha) + } + convenience init(hex: UInt, alpha: CGFloat = 1) { + self.init(red: .init((hex & 0xff0000) >> 16) / 255, + green: .init((hex & 0xff00 ) >> 8) / 255, + blue: .init( hex & 0xff ) / 255, + alpha: alpha) + } +}