Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Support dynamic font size #41

Open
tedgonzalez opened this issue Dec 15, 2019 · 1 comment
Open

Support dynamic font size #41

tedgonzalez opened this issue Dec 15, 2019 · 1 comment

Comments

@tedgonzalez
Copy link
Contributor

source: https://developer.apple.com/videos/play/wwdc2017/245/

system font

label.font = UIFont.preferredFont(forTextStyle: style)
label.adjustsFontForContentSizeCategory = true

where style is based on:
Screen Shot 2019-12-15 at 10 23 11 AM

custom font

/// ios 11 
label.font = UIFontMetrics.default.scaledFont(for: customFont) //default means .body
label.font = UIFontMetrics(forTextStyle: style).scaledFont(for: customFont)

/// Make sure to set lines to 0

label.numberOfLines = 0

layout (Auto layout Techniques in Interface Builder WWDC 2017)

secondLabel.firstBaselineAnchor.constraintEqualToSystemSpacingBelow(firstLabel.lastBaselineAnchor, multiplier: 1.0)

/// For side to side labels

if traitCollection.preferredContentSizeCategory > .extraLarge {
    // vertical stack
} else {
    // horizontal stack
}

/// updating layout when traitCollection changes

override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
    if traitCollection.preferredContentSizeCategory.isAccessibilityCategory != previousTraitCollection?.preferredContentSizeCategory.isAccessibilityCategory {
        /// updateLayout
    }
}

/// Table Views
/// standard table views with detail text label adjust automatically

tableView.rowHeight = UITableViewAutomaticDimension
tableView.estimatedRowHeight = <a reasonable estimate>

tableView.sectionHeaderHeight = UITableViewAutomaticDimension
tableView.estimatedSectionHeaderHeight = <a reasonable estimate>

tableView.sectionFooterHeight = UITableVIewAutomaticDimension
tableView.estimatedSectionFooterHeight = <a reasonable estimate>

/// images in UIImageView, UIButton, NSTextAttachment
Use pdf, preserve vector data checkbox in asset catalog
Interface builder
Screen Shot 2019-12-15 at 10 55 22 AM

imageView.adjustsImageSizeForAccessibilityContentSizeCategory = true

/// images in tabBarItems
Use pdf, preserve vector data checkbox in asset catalog
/// images in tabBarItems that doesn't have pdf
barButtonItem.largeContentSizeImage = largerImage

@tedgonzalez
Copy link
Contributor Author

Please start with destination address in app

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants