|
@@ -17,15 +17,12 @@
|
|
|
|
|
|
@implementation MASCompositeConstraint
|
|
|
|
|
|
-@synthesize delegate = _delegate;
|
|
|
-@synthesize updateExisting = _updateExisting;
|
|
|
-
|
|
|
- (id)initWithChildren:(NSArray *)children {
|
|
|
self = [super init];
|
|
|
if (!self) return nil;
|
|
|
|
|
|
_childConstraints = [children mutableCopy];
|
|
|
- for (id<MASConstraint> constraint in _childConstraints) {
|
|
|
+ for (MASConstraint *constraint in _childConstraints) {
|
|
|
constraint.delegate = self;
|
|
|
}
|
|
|
|
|
@@ -34,7 +31,7 @@
|
|
|
|
|
|
#pragma mark - MASConstraintDelegate
|
|
|
|
|
|
-- (void)constraint:(id<MASConstraint>)constraint shouldBeReplacedWithConstraint:(id<MASConstraint>)replacementConstraint {
|
|
|
+- (void)constraint:(MASConstraint *)constraint shouldBeReplacedWithConstraint:(MASConstraint *)replacementConstraint {
|
|
|
NSUInteger index = [self.childConstraints indexOfObject:constraint];
|
|
|
NSAssert(index != NSNotFound, @"Could not find constraint %@", constraint);
|
|
|
[self.childConstraints replaceObjectAtIndex:index withObject:replacementConstraint];
|
|
@@ -42,28 +39,28 @@
|
|
|
|
|
|
#pragma mark - NSLayoutConstraint constant proxies
|
|
|
|
|
|
-- (id<MASConstraint> (^)(MASEdgeInsets))insets {
|
|
|
+- (MASConstraint * (^)(MASEdgeInsets))insets {
|
|
|
return ^id(MASEdgeInsets insets) {
|
|
|
self.insets = insets;
|
|
|
return self;
|
|
|
};
|
|
|
}
|
|
|
|
|
|
-- (id<MASConstraint> (^)(CGFloat))offset {
|
|
|
+- (MASConstraint * (^)(CGFloat))offset {
|
|
|
return ^id(CGFloat offset) {
|
|
|
self.offset = offset;
|
|
|
return self;
|
|
|
};
|
|
|
}
|
|
|
|
|
|
-- (id<MASConstraint> (^)(CGSize))sizeOffset {
|
|
|
+- (MASConstraint * (^)(CGSize))sizeOffset {
|
|
|
return ^id(CGSize offset) {
|
|
|
self.sizeOffset = offset;
|
|
|
return self;
|
|
|
};
|
|
|
}
|
|
|
|
|
|
-- (id<MASConstraint> (^)(CGPoint))centerOffset {
|
|
|
+- (MASConstraint * (^)(CGPoint))centerOffset {
|
|
|
return ^id(CGPoint offset) {
|
|
|
self.centerOffset = offset;
|
|
|
return self;
|
|
@@ -72,18 +69,18 @@
|
|
|
|
|
|
#pragma mark - NSLayoutConstraint multiplier proxies
|
|
|
|
|
|
-- (id<MASConstraint> (^)(CGFloat))multipliedBy {
|
|
|
+- (MASConstraint * (^)(CGFloat))multipliedBy {
|
|
|
return ^id(CGFloat multiplier) {
|
|
|
- for (id<MASConstraint> constraint in self.childConstraints) {
|
|
|
+ for (MASConstraint *constraint in self.childConstraints) {
|
|
|
constraint.multipliedBy(multiplier);
|
|
|
}
|
|
|
return self;
|
|
|
};
|
|
|
}
|
|
|
|
|
|
-- (id<MASConstraint> (^)(CGFloat))dividedBy {
|
|
|
+- (MASConstraint * (^)(CGFloat))dividedBy {
|
|
|
return ^id(CGFloat divider) {
|
|
|
- for (id<MASConstraint> constraint in self.childConstraints) {
|
|
|
+ for (MASConstraint *constraint in self.childConstraints) {
|
|
|
constraint.dividedBy(divider);
|
|
|
}
|
|
|
return self;
|
|
@@ -92,30 +89,30 @@
|
|
|
|
|
|
#pragma mark - MASLayoutPriority proxies
|
|
|
|
|
|
-- (id<MASConstraint> (^)(MASLayoutPriority))priority {
|
|
|
+- (MASConstraint * (^)(MASLayoutPriority))priority {
|
|
|
return ^id(MASLayoutPriority priority) {
|
|
|
- for (id<MASConstraint> constraint in self.childConstraints) {
|
|
|
+ for (MASConstraint *constraint in self.childConstraints) {
|
|
|
constraint.priority(priority);
|
|
|
}
|
|
|
return self;
|
|
|
};
|
|
|
}
|
|
|
|
|
|
-- (id<MASConstraint> (^)())priorityLow {
|
|
|
+- (MASConstraint * (^)())priorityLow {
|
|
|
return ^id{
|
|
|
self.priority(MASLayoutPriorityDefaultLow);
|
|
|
return self;
|
|
|
};
|
|
|
}
|
|
|
|
|
|
-- (id<MASConstraint> (^)())priorityMedium {
|
|
|
+- (MASConstraint * (^)())priorityMedium {
|
|
|
return ^id{
|
|
|
self.priority(MASLayoutPriorityDefaultMedium);
|
|
|
return self;
|
|
|
};
|
|
|
}
|
|
|
|
|
|
-- (id<MASConstraint> (^)())priorityHigh {
|
|
|
+- (MASConstraint * (^)())priorityHigh {
|
|
|
return ^id{
|
|
|
self.priority(MASLayoutPriorityDefaultHigh);
|
|
|
return self;
|
|
@@ -124,27 +121,27 @@
|
|
|
|
|
|
#pragma mark - NSLayoutRelation proxies
|
|
|
|
|
|
-- (id<MASConstraint> (^)(id))equalTo {
|
|
|
+- (MASConstraint * (^)(id))equalTo {
|
|
|
return ^id(id attr) {
|
|
|
- for (id<MASConstraint> constraint in self.childConstraints.copy) {
|
|
|
+ for (MASConstraint *constraint in self.childConstraints.copy) {
|
|
|
constraint.equalTo(attr);
|
|
|
}
|
|
|
return self;
|
|
|
};
|
|
|
}
|
|
|
|
|
|
-- (id<MASConstraint> (^)(id))greaterThanOrEqualTo {
|
|
|
+- (MASConstraint * (^)(id))greaterThanOrEqualTo {
|
|
|
return ^id(id attr) {
|
|
|
- for (id<MASConstraint> constraint in self.childConstraints.copy) {
|
|
|
+ for (MASConstraint *constraint in self.childConstraints.copy) {
|
|
|
constraint.greaterThanOrEqualTo(attr);
|
|
|
}
|
|
|
return self;
|
|
|
};
|
|
|
}
|
|
|
|
|
|
-- (id<MASConstraint> (^)(id))lessThanOrEqualTo {
|
|
|
+- (MASConstraint * (^)(id))lessThanOrEqualTo {
|
|
|
return ^id(id attr) {
|
|
|
- for (id<MASConstraint> constraint in self.childConstraints.copy) {
|
|
|
+ for (MASConstraint *constraint in self.childConstraints.copy) {
|
|
|
constraint.lessThanOrEqualTo(attr);
|
|
|
}
|
|
|
return self;
|
|
@@ -153,7 +150,7 @@
|
|
|
|
|
|
#pragma mark - Semantic properties
|
|
|
|
|
|
-- (id<MASConstraint>)with {
|
|
|
+- (MASConstraint *)with {
|
|
|
return self;
|
|
|
}
|
|
|
|
|
@@ -161,8 +158,8 @@
|
|
|
|
|
|
#if TARGET_OS_MAC && !TARGET_OS_IPHONE
|
|
|
|
|
|
-- (id<MASConstraint>)animator {
|
|
|
- for (id<MASConstraint> constraint in self.childConstraints) {
|
|
|
+- (MASConstraint *)animator {
|
|
|
+ for (MASConstraint *constraint in self.childConstraints) {
|
|
|
[constraint animator];
|
|
|
}
|
|
|
return self;
|
|
@@ -172,11 +169,11 @@
|
|
|
|
|
|
#pragma mark - debug helpers
|
|
|
|
|
|
-- (id<MASConstraint> (^)(id))key {
|
|
|
+- (MASConstraint * (^)(id))key {
|
|
|
return ^id(id key) {
|
|
|
self.mas_key = key;
|
|
|
int i = 0;
|
|
|
- for (id<MASConstraint> constraint in self.childConstraints) {
|
|
|
+ for (MASConstraint *constraint in self.childConstraints) {
|
|
|
constraint.key([NSString stringWithFormat:@"%@[%d]", key, i++]);
|
|
|
}
|
|
|
return self;
|
|
@@ -186,25 +183,25 @@
|
|
|
#pragma mark - NSLayoutConstraint constant setters
|
|
|
|
|
|
- (void)setInsets:(MASEdgeInsets)insets {
|
|
|
- for (id<MASConstraint> constraint in self.childConstraints) {
|
|
|
+ for (MASConstraint *constraint in self.childConstraints) {
|
|
|
constraint.insets = insets;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- (void)setOffset:(CGFloat)offset {
|
|
|
- for (id<MASConstraint> constraint in self.childConstraints) {
|
|
|
+ for (MASConstraint *constraint in self.childConstraints) {
|
|
|
constraint.offset = offset;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- (void)setSizeOffset:(CGSize)sizeOffset {
|
|
|
- for (id<MASConstraint> constraint in self.childConstraints) {
|
|
|
+ for (MASConstraint *constraint in self.childConstraints) {
|
|
|
constraint.sizeOffset = sizeOffset;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- (void)setCenterOffset:(CGPoint)centerOffset {
|
|
|
- for (id<MASConstraint> constraint in self.childConstraints) {
|
|
|
+ for (MASConstraint *constraint in self.childConstraints) {
|
|
|
constraint.centerOffset = centerOffset;
|
|
|
}
|
|
|
}
|
|
@@ -212,14 +209,14 @@
|
|
|
#pragma mark - MASConstraint
|
|
|
|
|
|
- (void)install {
|
|
|
- for (id<MASConstraint> constraint in self.childConstraints) {
|
|
|
+ for (MASConstraint *constraint in self.childConstraints) {
|
|
|
constraint.updateExisting = self.updateExisting;
|
|
|
[constraint install];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- (void)uninstall {
|
|
|
- for (id<MASConstraint> constraint in self.childConstraints) {
|
|
|
+ for (MASConstraint *constraint in self.childConstraints) {
|
|
|
[constraint uninstall];
|
|
|
}
|
|
|
}
|