Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ZeroConstraint: NSLayoutConstraint {
- public override var constant: CGFloat {
- get {
- let adjustedConstraint = super.constant * SizeAdjustment.percentage
- return adjustedConstraint
- }
- set { super.constant = newValue }
- }
- }
- struct SizeAdjustment {
- // The percentage each element should scale by
- static var percentage: CGFloat = {
- // We design everything at this width (iPhone X). Scale up or down in
- // relation to it.
- let baseWidth: CGFloat = 375.0
- let percentage = UIScreen.main.bounds.width / baseWidth
- return percentage
- }()
- }
Add Comment
Please, Sign In to add comment