diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a6e4eb2..bba6536a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +### 0.9.18 +- **Add**: `hexString` property for `UIColor` that returns hex representation of color as string. + ### 0.9.17 - **Fix**: SpinnerView infinity animation. diff --git a/Sources/Classes/Search/BaseSearchViewController.swift b/Sources/Classes/Search/BaseSearchViewController.swift index 2e170cc1..ce84d686 100644 --- a/Sources/Classes/Search/BaseSearchViewController.swift +++ b/Sources/Classes/Search/BaseSearchViewController.swift @@ -27,7 +27,7 @@ import UIKit public typealias SearchResultsController = UIViewController & SearchResultsViewController /// Class that allows to enter text for search and then displays search results in table view -open class BaseSearchViewController: BaseCustomViewController diff --git a/Sources/Extensions/UIColor/UIColor+Hex.swift b/Sources/Extensions/UIColor/UIColor+Hex.swift index 8633d397..482ad38f 100644 --- a/Sources/Extensions/UIColor/UIColor+Hex.swift +++ b/Sources/Extensions/UIColor/UIColor+Hex.swift @@ -126,3 +126,24 @@ public extension UIColor { } } } + +public extension UIColor { + + /// Hex representation of UIColor as String + var hexString: String { + var red: CGFloat = 0 + var green: CGFloat = 0 + var blue: CGFloat = 0 + var alpha: CGFloat = 0 + + getRed(&red, green: &green, blue: &blue, alpha: &alpha) + + let intRepresentation = alpha == 1 + ? Int(red * 255) << 16 | Int(green * 255) << 8 | Int(blue * 255) << 0 + : Int(red * 255) << 24 | Int(green * 255) << 16 | Int(blue * 255) << 8 | Int(alpha * 255) << 0 + + return alpha == 1 + ? String(format: "#%06x", intRepresentation) + : String(format: "#%08x", intRepresentation) + } +} diff --git a/Sources/Info-iOS.plist b/Sources/Info-iOS.plist index 3cdbc79b..a15de67d 100644 --- a/Sources/Info-iOS.plist +++ b/Sources/Info-iOS.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 0.9.17 + 0.9.18 CFBundleVersion $(CURRENT_PROJECT_VERSION) NSPrincipalClass diff --git a/Sources/Info-tvOS.plist b/Sources/Info-tvOS.plist index 3cdbc79b..a15de67d 100644 --- a/Sources/Info-tvOS.plist +++ b/Sources/Info-tvOS.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 0.9.17 + 0.9.18 CFBundleVersion $(CURRENT_PROJECT_VERSION) NSPrincipalClass diff --git a/Sources/Info-watchOS.plist b/Sources/Info-watchOS.plist index 3cdbc79b..a15de67d 100644 --- a/Sources/Info-watchOS.plist +++ b/Sources/Info-watchOS.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 0.9.17 + 0.9.18 CFBundleVersion $(CURRENT_PROJECT_VERSION) NSPrincipalClass diff --git a/Sources/Structures/Api/ApiUploadRequestParameters.swift b/Sources/Structures/Api/ApiUploadRequestParameters.swift index 3ef4bb3f..9cfa9fad 100644 --- a/Sources/Structures/Api/ApiUploadRequestParameters.swift +++ b/Sources/Structures/Api/ApiUploadRequestParameters.swift @@ -102,7 +102,7 @@ private extension ApiUploadRequestParameters { fileExtension as CFString, nil)?.takeRetainedValue(), let mimeType = UTTypeCopyPreferredTagWithClass(utiType, - kUTTagClassMIMEType)?.takeRetainedValue() as? String else { + kUTTagClassMIMEType)?.takeRetainedValue() as String? else { assertionFailure("Unable to get mime type from file name") throw UploadParametersError.unableGetMimeType