We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
class Device { // 以 iPhone 6 尺寸为设计稿 static let base: CGFloat = 375 static var ratio: CGFloat { return UIScreen.main.bounds.width / base } } xtension CGFloat { var adjusted: CGFloat { return self * Device.ratio } } extension Double { var adjusted: CGFloat { return CGFloat(self) * Device.ratio } } extension Int { var adjusted: CGFloat { return CGFloat(self) * Device.ratio } }
label.font = UIFont.systemFont(ofSize: 23.adjusted) phoneTextField.leftAnchor.constraint(equalTo: container.leftAnchor, constant: 30.adjusted) phoneTextField.rightAnchor.constraint(equalTo: container.rightAnchor, constant: -30.adjusted) imageView.widthAnchor.constraint(equalToConstant: 80.adjusted) imageView.heightAnchor.constraint(equalToConstant: 90.adjusted)
How to handle Auto Layout with different screen sizes
The text was updated successfully, but these errors were encountered:
No branches or pull requests
How to handle Auto Layout with different screen sizes
The text was updated successfully, but these errors were encountered: