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:24
Blog post / Dynamic Type - Custom font improved to work with unwrapped font
extension CustomFont where Self: RawRepresentable, Self.RawValue == String {
func sized(_ size: CGFloat) -> UIFont {
return UIFont(name: self.rawValue, size: size).unwrapped
}
}
@marinofelipe
marinofelipe / CustomFont.swift
Last active March 13, 2019 04:12
Blog post / Dynamic Type - Custom font protocol extended for enums that has RawValue of type String
protocol CustomFont {
func sized(_ size: CGFloat) -> UIFont?
}
extension CustomFont where Self: RawRepresentable, Self.RawValue == String {
func sized(_ size: CGFloat) -> UIFont? {
return UIFont(name: self.rawValue, size: size)
}
}
@marinofelipe
marinofelipe / UILabel.swift
Last active March 13, 2019 04:13
Blog post / Dynamic Type - Passing a custom font to label's font
label.font = UIFont.jurassicPark.semibold.sized(30.0)
@marinofelipe
marinofelipe / UILabel.swift
Last active March 13, 2019 04:14
Blog post / Dynamic Type - Setting a custom scalable font with max size to a label
label.font = UIFont.jurassicPark.regular.sized(40.0).scaled(forTextStyle: .body, maxSize: 80.0)
- name: Swift by Sundell
rss_url: https://swiftbysundell.com/rss
logo_url: https://www.google.com/s2/favicons?sz=256&domain_url=www.swiftbysundell.com
- name: Swift Wings
rss_url: https://www.onswiftwings.com/index.xml
- name: Swift Rocks
rss_url: https://swiftrocks.com/rss.xml