Authored by Paulo F. Andrade

Adding support for the animator proxy on OS X

... ... @@ -165,6 +165,22 @@
return self;
}
#pragma mark - Animator proxy
#if TARGET_OS_MAC && !TARGET_OS_IPHONE
- (id<MASConstraint>)animator
{
for (id<MASConstraint> constraint in self.childConstraints) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-value"
constraint.animator;
#pragma clang diagnostic pop
}
return self;
}
#endif
#pragma mark - debug helpers
- (id<MASConstraint> (^)(id))key {
... ...
... ... @@ -113,6 +113,13 @@
*/
@property (nonatomic, copy, readonly) id<MASConstraint> (^key)(id key);
#if TARGET_OS_MAC && !TARGET_OS_IPHONE
/**
* Whether or not to go through the animator proxy when modifying the constraint
*/
@property (nonatomic, copy, readonly) id<MASConstraint> animator;
#endif
/**
* Whether or not to check for an existing constraint instead of adding constraint
*/
... ...
... ... @@ -22,6 +22,7 @@
@property (nonatomic, assign) CGFloat layoutConstant;
@property (nonatomic, assign) BOOL hasLayoutRelation;
@property (nonatomic, strong) id mas_key;
@property (nonatomic, assign) BOOL useAnimator;
@end
... ... @@ -57,7 +58,16 @@
- (void)setLayoutConstant:(CGFloat)layoutConstant {
_layoutConstant = layoutConstant;
#if TARGET_OS_MAC && !TARGET_OS_IPHONE
if(self.useAnimator) {
self.layoutConstraint.animator.constant = layoutConstant;
} else {
self.layoutConstraint.constant = layoutConstant;
}
#else
self.layoutConstraint.constant = layoutConstant;
#endif
}
- (void)setLayoutRelation:(NSLayoutRelation)layoutRelation {
... ... @@ -247,6 +257,18 @@
return self;
}
#pragma mark - Animator proxy
#if TARGET_OS_MAC && !TARGET_OS_IPHONE
- (id<MASConstraint>)animator
{
self.useAnimator = YES;
return self;
}
#endif
#pragma mark - debug helpers
- (id<MASConstraint> (^)(id))key {
... ...