-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDeviceConstraint.swift
43 lines (40 loc) · 1.44 KB
/
DeviceConstraint.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//
// DeviceConstraint.swift
//
//
// Created by Mikhail Panfilov on 24.12.2019.
// Copyright © 2019 Mikhail Panfilov. All rights reserved.
//
import UIKit
@IBDesignable class DeviceConstraint: NSLayoutConstraint {
@IBInspectable var iPhoneSE: CGFloat = 0.0 {
didSet { deviceConstant(DeviceType.iPhoneSE, value: iPhoneSE) }
}
@IBInspectable var iPhoneWithoutTopNotch: CGFloat = 0.0 {
didSet { deviceConstant(DeviceType.iPhoneWithoutTopNotch, value: iPhoneWithoutTopNotch) }
}
@IBInspectable var iPhonePlus: CGFloat = 0.0 {
didSet { deviceConstant(DeviceType.iPhonePlus, value: iPhonePlus) }
}
@IBInspectable var iPhoneXOr12Mini: CGFloat = 0.0 {
didSet { deviceConstant(DeviceType.iPhoneXOr12Mini, value: iPhoneXOr12Mini) }
}
@IBInspectable var iPhoneXrOrMax: CGFloat = 0.0 {
didSet { deviceConstant(DeviceType.iPhoneXrOrMax, value: iPhoneXrOrMax) }
}
@IBInspectable var iPhone12: CGFloat = 0.0 {
didSet { deviceConstant(DeviceType.iPhone12, value: iPhone12) }
}
@IBInspectable var iPhone12Max: CGFloat = 0.0 {
didSet { deviceConstant(DeviceType.iPhone12Max, value: iPhone12Max) }
}
@IBInspectable var iPad: CGFloat = 0.0 {
didSet { deviceConstant(DeviceType.iPad, value: iPad) }
}
// Helpers
open func deviceConstant(_ currentDevice: Bool, value: CGFloat) {
if currentDevice {
constant = value
}
}
}