Merge pull request #41 from pfandrade/upstream
Adding support for the animator proxy on OS X
Showing
3 changed files
with
41 additions
and
0 deletions
@@ -165,6 +165,19 @@ | @@ -165,6 +165,19 @@ | ||
165 | return self; | 165 | return self; |
166 | } | 166 | } |
167 | 167 | ||
168 | +#pragma mark - Animator proxy | ||
169 | + | ||
170 | +#if TARGET_OS_MAC && !TARGET_OS_IPHONE | ||
171 | + | ||
172 | +- (id<MASConstraint>)animator { | ||
173 | + for (id<MASConstraint> constraint in self.childConstraints) { | ||
174 | + [constraint animator]; | ||
175 | + } | ||
176 | + return self; | ||
177 | +} | ||
178 | + | ||
179 | +#endif | ||
180 | + | ||
168 | #pragma mark - debug helpers | 181 | #pragma mark - debug helpers |
169 | 182 | ||
170 | - (id<MASConstraint> (^)(id))key { | 183 | - (id<MASConstraint> (^)(id))key { |
@@ -113,6 +113,13 @@ | @@ -113,6 +113,13 @@ | ||
113 | */ | 113 | */ |
114 | @property (nonatomic, copy, readonly) id<MASConstraint> (^key)(id key); | 114 | @property (nonatomic, copy, readonly) id<MASConstraint> (^key)(id key); |
115 | 115 | ||
116 | +#if TARGET_OS_MAC && !TARGET_OS_IPHONE | ||
117 | +/** | ||
118 | + * Whether or not to go through the animator proxy when modifying the constraint | ||
119 | + */ | ||
120 | +@property (nonatomic, copy, readonly) id<MASConstraint> animator; | ||
121 | +#endif | ||
122 | + | ||
116 | /** | 123 | /** |
117 | * Whether or not to check for an existing constraint instead of adding constraint | 124 | * Whether or not to check for an existing constraint instead of adding constraint |
118 | */ | 125 | */ |
@@ -22,6 +22,7 @@ | @@ -22,6 +22,7 @@ | ||
22 | @property (nonatomic, assign) CGFloat layoutConstant; | 22 | @property (nonatomic, assign) CGFloat layoutConstant; |
23 | @property (nonatomic, assign) BOOL hasLayoutRelation; | 23 | @property (nonatomic, assign) BOOL hasLayoutRelation; |
24 | @property (nonatomic, strong) id mas_key; | 24 | @property (nonatomic, strong) id mas_key; |
25 | +@property (nonatomic, assign) BOOL useAnimator; | ||
25 | 26 | ||
26 | @end | 27 | @end |
27 | 28 | ||
@@ -57,7 +58,16 @@ | @@ -57,7 +58,16 @@ | ||
57 | 58 | ||
58 | - (void)setLayoutConstant:(CGFloat)layoutConstant { | 59 | - (void)setLayoutConstant:(CGFloat)layoutConstant { |
59 | _layoutConstant = layoutConstant; | 60 | _layoutConstant = layoutConstant; |
61 | + | ||
62 | +#if TARGET_OS_MAC && !TARGET_OS_IPHONE | ||
63 | + if(self.useAnimator) { | ||
64 | + self.layoutConstraint.animator.constant = layoutConstant; | ||
65 | + } else { | ||
66 | + self.layoutConstraint.constant = layoutConstant; | ||
67 | + } | ||
68 | +#else | ||
60 | self.layoutConstraint.constant = layoutConstant; | 69 | self.layoutConstraint.constant = layoutConstant; |
70 | +#endif | ||
61 | } | 71 | } |
62 | 72 | ||
63 | - (void)setLayoutRelation:(NSLayoutRelation)layoutRelation { | 73 | - (void)setLayoutRelation:(NSLayoutRelation)layoutRelation { |
@@ -247,6 +257,17 @@ | @@ -247,6 +257,17 @@ | ||
247 | return self; | 257 | return self; |
248 | } | 258 | } |
249 | 259 | ||
260 | +#pragma mark - Animator proxy | ||
261 | + | ||
262 | +#if TARGET_OS_MAC && !TARGET_OS_IPHONE | ||
263 | + | ||
264 | +- (id<MASConstraint>)animator { | ||
265 | + self.useAnimator = YES; | ||
266 | + return self; | ||
267 | +} | ||
268 | + | ||
269 | +#endif | ||
270 | + | ||
250 | #pragma mark - debug helpers | 271 | #pragma mark - debug helpers |
251 | 272 | ||
252 | - (id<MASConstraint> (^)(id))key { | 273 | - (id<MASConstraint> (^)(id))key { |
-
Please register or login to post a comment