File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,8 @@ NS_ASSUME_NONNULL_BEGIN
15
15
@property (nonatomic , strong , nullable ) IBOutlet UIView *parentView;
16
16
@property (nonatomic , assign ) IBInspectable CGFloat relationMultiplier;
17
17
@property (nonatomic , assign ) IBInspectable CGFloat additionalConstant;
18
+ @property (nonatomic , assign ) IBInspectable CGFloat minimumConstant;
19
+ @property (nonatomic , assign ) IBInspectable CGFloat maximumConstant;
18
20
19
21
- (void )setNeedsConstantUpdate ;
20
22
Original file line number Diff line number Diff line change @@ -31,6 +31,8 @@ + (void)load
31
31
32
32
- (void )setDefaults
33
33
{
34
+ _minimumConstant = nanf (NULL );
35
+ _maximumConstant = nanf (NULL );
34
36
}
35
37
36
38
- (void )setParentView : (nullable UIView *)parentView
@@ -62,9 +64,31 @@ - (void)setAdditionalConstant:(CGFloat)additionalConstant
62
64
[self setNeedsConstantUpdate ];
63
65
}
64
66
67
+ - (void )setMinimumConstant : (CGFloat)minimumConstant
68
+ {
69
+ _minimumConstant = minimumConstant;
70
+ [self setNeedsConstantUpdate ];
71
+ }
72
+
73
+ - (void )setMaximumConstant : (CGFloat)maximumConstant
74
+ {
75
+ _maximumConstant = maximumConstant;
76
+ [self setNeedsConstantUpdate ];
77
+ }
78
+
65
79
- (void )setNeedsConstantUpdate
66
80
{
67
- self.constant = ([self updatedConstant ] * self.relationMultiplier ) + self.additionalConstant ;
81
+ CGFloat newConstant = ([self updatedConstant ] * self.relationMultiplier ) + self.additionalConstant ;
82
+
83
+ if (!isnan (self.minimumConstant )) {
84
+ newConstant = MAX (self.minimumConstant , newConstant);
85
+ }
86
+
87
+ if (!isnan (self.maximumConstant )) {
88
+ newConstant = MIN (self.maximumConstant , newConstant);
89
+ }
90
+
91
+ self.constant = newConstant;
68
92
}
69
93
70
94
- (CGFloat)updatedConstant
You can’t perform that action at this time.
0 commit comments