-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #56 from cloudkite/attribute_chaining
Add ability to chain different view attributes
- Loading branch information
Showing
16 changed files
with
334 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
Examples/Masonry iOS Examples/MASExampleAttributeChainingView.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// | ||
// MASExampleAttributeChainingView.h | ||
// Masonry iOS Examples | ||
// | ||
// Created by Jonas Budelmann on 31/03/14. | ||
// Copyright (c) 2014 Jonas Budelmann. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface MASExampleAttributeChainingView : UIView | ||
|
||
@end |
77 changes: 77 additions & 0 deletions
77
Examples/Masonry iOS Examples/MASExampleAttributeChainingView.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// | ||
// MASExampleAttributeChainingView.m | ||
// Masonry iOS Examples | ||
// | ||
// Created by Jonas Budelmann on 31/03/14. | ||
// Copyright (c) 2014 Jonas Budelmann. All rights reserved. | ||
// | ||
|
||
#import "MASExampleAttributeChainingView.h" | ||
|
||
@implementation MASExampleAttributeChainingView | ||
|
||
- (id)init { | ||
self = [super init]; | ||
if (!self) return nil; | ||
|
||
UIView *view1 = UIView.new; | ||
view1.backgroundColor = UIColor.greenColor; | ||
view1.layer.borderColor = UIColor.blackColor.CGColor; | ||
view1.layer.borderWidth = 2; | ||
[self addSubview:view1]; | ||
|
||
UIView *view2 = UIView.new; | ||
view2.backgroundColor = UIColor.redColor; | ||
view2.layer.borderColor = UIColor.blackColor.CGColor; | ||
view2.layer.borderWidth = 2; | ||
[self addSubview:view2]; | ||
|
||
UIView *view3 = UIView.new; | ||
view3.backgroundColor = UIColor.blueColor; | ||
view3.layer.borderColor = UIColor.blackColor.CGColor; | ||
view3.layer.borderWidth = 2; | ||
[self addSubview:view3]; | ||
|
||
UIView *superview = self; | ||
UIEdgeInsets padding = UIEdgeInsetsMake(15, 10, 15, 10); | ||
|
||
|
||
[view1 mas_makeConstraints:^(MASConstraintMaker *make) { | ||
// chain attributes | ||
make.top.and.left.greaterThanOrEqualTo(superview).insets(padding); | ||
|
||
// which is the equivalent of | ||
// make.top.greaterThanOrEqualTo(superview).insets(padding); | ||
// make.left.greaterThanOrEqualTo(superview).insets(padding); | ||
|
||
make.bottom.equalTo(view3.mas_top).insets(padding); | ||
make.right.equalTo(view2.mas_left).insets(padding); | ||
make.width.equalTo(view2.mas_width); | ||
|
||
make.height.equalTo(@[view2, view3]); | ||
}]; | ||
|
||
[view2 mas_makeConstraints:^(MASConstraintMaker *make) { | ||
// chain attributes | ||
make.top.and.right.equalTo(superview).insets(padding); | ||
|
||
make.left.equalTo(view1.mas_right).insets(padding); | ||
make.bottom.equalTo(view3.mas_top).insets(padding); | ||
make.width.equalTo(view1.mas_width); | ||
|
||
make.height.equalTo(@[view1, view3]); | ||
}]; | ||
|
||
[view3 mas_makeConstraints:^(MASConstraintMaker *make) { | ||
make.top.equalTo(view1.mas_bottom).insets(padding); | ||
|
||
// chain attributes | ||
make.left.right.and.bottom.equalTo(superview).insets(padding); | ||
|
||
make.height.equalTo(@[view1, view2]); | ||
}]; | ||
|
||
return self; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.