-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
source: https://developer.apple.com/videos/play/wwdc2017/245/
system font
label.font = UIFont.preferredFont(forTextStyle: style)
label.adjustsFontForContentSizeCategory = true
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
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
Metadata
Metadata
Assignees
Labels
No labels