diff --git a/README.md b/README.md index 974aa4f..b9c007d 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ A µFramework for showing alerts like the one used when copying from pasteboard - iOS 13+ - Can be used in SwiftUI and UIKit applications - Light/Dark modes +- Custom colors for title, subtitle and icon - Interactive dismissal - Queue to show consecutive drops - Support dynamic font sizing @@ -54,7 +55,8 @@ let drop = Drop( }, position: .bottom, duration: 5.0, - accessibility: "Alert: Title, Subtitle" + accessibility: "Alert: Title, Subtitle", + titleColor: .blue ) ``` diff --git a/Sources/Drop.swift b/Sources/Drop.swift index 9ba98dc..c40e89a 100644 --- a/Sources/Drop.swift +++ b/Sources/Drop.swift @@ -40,6 +40,9 @@ public struct Drop: ExpressibleByStringLiteral { /// - position: Position. Defaults to `Drop.Position.top`. /// - duration: Duration. Defaults to `Drop.Duration.recommended`. /// - accessibility: Accessibility options. Defaults to `nil` which will use "title, subtitle" as its message. + /// - titleColor: Title color. Defaults to `.label`. + /// - subtitleColor: Subtitle color. Defaults to `.secondaryLabel`. + /// - iconColor: Icon color. Defaults to `.secondaryLabel`. public init( title: String, titleNumberOfLines: Int = 1, @@ -49,7 +52,10 @@ public struct Drop: ExpressibleByStringLiteral { action: Action? = nil, position: Position = .top, duration: Duration = .recommended, - accessibility: Accessibility? = nil + accessibility: Accessibility? = nil, + titleColor: UIColor = .label, + subtitleColor: UIColor = .secondaryLabel, + iconColor: UIColor = .secondaryLabel ) { self.title = title.trimmingCharacters(in: .whitespacesAndNewlines) self.titleNumberOfLines = titleNumberOfLines @@ -63,6 +69,9 @@ public struct Drop: ExpressibleByStringLiteral { self.duration = duration self.accessibility = accessibility ?? .init(message: [title, subtitle].compactMap { $0 }.joined(separator: ", ")) + self.titleColor = titleColor + self.subtitleColor = subtitleColor + self.iconColor = iconColor } /// Create a new accessibility object. @@ -74,6 +83,9 @@ public struct Drop: ExpressibleByStringLiteral { position = .top duration = .recommended accessibility = .init(message: title) + titleColor = .label + subtitleColor = .secondaryLabel + iconColor = .secondaryLabel } /// Title. @@ -102,6 +114,15 @@ public struct Drop: ExpressibleByStringLiteral { /// Accessibility. public var accessibility: Accessibility + + /// Title Color. + public var titleColor: UIColor + + /// Subtitle Color. + public var subtitleColor: UIColor + + /// Title Color. + public var iconColor: UIColor } public extension Drop { diff --git a/Sources/DropView.swift b/Sources/DropView.swift index 2b034a2..68960e6 100644 --- a/Sources/DropView.swift +++ b/Sources/DropView.swift @@ -105,13 +105,16 @@ internal final class DropView: UIView { titleLabel.text = drop.title titleLabel.numberOfLines = drop.titleNumberOfLines + titleLabel.textColor = drop.titleColor subtitleLabel.text = drop.subtitle subtitleLabel.numberOfLines = drop.subtitleNumberOfLines subtitleLabel.isHidden = drop.subtitle == nil + subtitleLabel.textColor = drop.subtitleColor imageView.image = drop.icon imageView.isHidden = drop.icon == nil + imageView.tintColor = drop.iconColor button.setImage(drop.action?.icon, for: .normal) button.isHidden = drop.action?.icon == nil