Skip to content

Instantly share code, notes, and snippets.

View marinofelipe's full-sized avatar
👨‍💻
Focusing

Felipe Marino marinofelipe

👨‍💻
Focusing
View GitHub Profile
@marinofelipe
marinofelipe / CustomFont.swift
Last active April 8, 2019 03:23
Blog post / Dynamic Type - App's custom fonts enumeration
enum jurassicPark: String {
case
regular = "JurassicPark-Regular",
semibold = "JurassicPark-Semibold",
bold = "JurassicPark-Bold"
}
@marinofelipe
marinofelipe / ViewController.swift
Last active April 8, 2019 03:23
Blog post / Dynamic Type - Setting a scaled custom font using UIFontMetrics with title1 text style
if #available(iOS 11.0, *) {
if let font = UIFont(name: "custom", size: 20.0) {
label.font = UIFontMetrics(forTextStyle: .title1).scaledFont(for: font)
}
}
@marinofelipe
marinofelipe / ViewController.swift
Last active April 8, 2019 03:22
Blog post / Dynamic Type - Shows how to listen to content size category changes above and under iOS 10
private func adjustForContentSizeCategoryChanges() {
if #available(iOS 10.0, *) {
label.adjustsFontForContentSizeCategory = true
} else {
NotificationCenter.default.addObserver(self,
selector: #selector(self.didChangeContentSizeCategory),
name: UIContentSizeCategory.didChangeNotification,
object: nil)
}
}
@marinofelipe
marinofelipe / ViewController.swift
Last active April 8, 2019 03:22
Blog post / Dynamic Type - Setting a dynamic size text to a label using one of system's built-in text styles
label.font = UIFont.preferedFont(forTextStyle: .body)