Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fontSize Configurator parameter #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Source/Squawk+Configuration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -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
Expand All @@ -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
}
1 change: 1 addition & 0 deletions Source/SquawkView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down