From c691063e85c5761f761254c563b67f92c060d4e7 Mon Sep 17 00:00:00 2001 From: Exey Panteleev Date: Mon, 4 Mar 2019 13:43:24 +0300 Subject: [PATCH] fontSize Configurator parameter --- Source/Squawk+Configuration.swift | 11 +++++++++++ Source/SquawkView.swift | 1 + 2 files changed, 12 insertions(+) diff --git a/Source/Squawk+Configuration.swift b/Source/Squawk+Configuration.swift index 237d192..5dd1298 100644 --- a/Source/Squawk+Configuration.swift +++ b/Source/Squawk+Configuration.swift @@ -14,6 +14,7 @@ public extension Squawk { let text: String let textColor: UIColor + let fontSize: FontSize let backgroundColor: UIColor let insets: UIEdgeInsets let maxWidth: CGFloat @@ -30,6 +31,7 @@ public extension Squawk { public init( text: String, textColor: UIColor = .white, + fontSize: FontSize = .medium, backgroundColor: UIColor = UIColor(white: 0.2, alpha: 0.7), insets: UIEdgeInsets = UIEdgeInsets(top: 8, left: 15, bottom: 8, right: 15), maxWidth: CGFloat = 300, @@ -45,6 +47,7 @@ public extension Squawk { ) { self.text = text self.textColor = textColor + self.fontSize = fontSize self.backgroundColor = backgroundColor self.insets = insets self.maxWidth = maxWidth @@ -61,3 +64,11 @@ public extension Squawk { } } + +public enum FontSize: CGFloat { + case smaller = 12 + case small = 14 + case medium = 16 + case large = 18 + case larger = 20 +} diff --git a/Source/SquawkView.swift b/Source/SquawkView.swift index 6c53bd1..2f505aa 100644 --- a/Source/SquawkView.swift +++ b/Source/SquawkView.swift @@ -37,6 +37,7 @@ internal final class SquawkView: UIView { label.numberOfLines = 0 label.textColor = configuration.textColor label.text = configuration.text + label.font = label.font.withSize(configuration.fontSize.rawValue) label.translatesAutoresizingMaskIntoConstraints = false label.backgroundColor = .clear contentView.addSubview(label)