Two additional attributes NSLayoutAttributeFirstBaseline
and NSLayoutAttributeLastBaseline
are now supported
Fixes some issues with install/uninstall vs activate/deactivate and modernises the project files
https://github.com/SnapKit/Masonry/pull/225
https://github.com/SnapKit/Masonry/pull/163
https://github.com/SnapKit/Masonry/pull/168
https://github.com/SnapKit/Masonry/pull/182
https://github.com/SnapKit/Masonry/pull/148
As of iOS 8 there is active
property of NSLayoutConstraint
available, which allows to (de)activate constraint without searching closest common superview.
https://github.com/Masonry/Masonry/pull/84
https://github.com/cloudkite/Masonry/issues/71
https://github.com/cloudkite/Masonry/pull/69
mas_updateConstraints
(Rolken)Was not checking that the constraint relation was equivalent https://github.com/cloudkite/Masonry/pull/65
mas_remakeConstraints
(nickynick)Similar to mas_updateConstraints
however instead of trying to update existing constraints it Removes all constraints previously defined and installed for the view, allowing you to provide replacements without hassle.
https://github.com/cloudkite/Masonry/pull/63
Autoboxing allows you to write equality relations and offsets by passing primitive values and structs
make.top.mas_equalTo(42);
make.height.mas_equalTo(20);
make.size.mas_equalTo(CGSizeMake(50, 100));
make.edges.mas_equalTo(UIEdgeInsetsMake(10, 0, 10, 0));
make.left.mas_equalTo(view).mas_offset(UIEdgeInsetsMake(10, 0, 10, 0));
by default these autoboxing macros are prefix with mas_
If you want the unprefixed version you need to add MAS_SHORTHAND_GLOBALS
before importing Masonry.h (ie in your Prefix.pch)
https://github.com/cloudkite/Masonry/pull/62
Composites are great for defining multiple attributes at once. The following example makes top, left, bottom, right equal to superview
.
make.edges.equalTo(superview).insets(padding);
However if only three of the sides are equal to superview
then we need to repeat quite a bit of code
make.left.equalTo(superview).insets(padding);
make.right.equalTo(superview).insets(padding);
make.bottom.equalTo(superview).insets(padding);
// top needs to be equal to `otherView`
make.top.equalTo(otherView).insets(padding);
This change makes it possible to chain view attributes to improve readability
make.left.right.and.bottom.equalTo(superview).insets(padding);
make.top.equalTo(otherView).insets(padding);
https://github.com/cloudkite/Masonry/pull/56
Breaking Changes
If you are holding onto any instances of masonry constraints ie
// in public/private interface
@property (nonatomic, strong) id<MASConstraint> topConstraint;
You will need to change this to
// in public/private interface
@property (nonatomic, strong) MASConstraint *topConstraint;
Instead of using protocols Masonry now uses an abstract base class for constraints in order to get Xcode auto-complete support see http://stackoverflow.com/questions/14534223/
self.leftConstraint.animator.offset(20);
offset
, centerOffset
, insets
, sizeOffset
.now you can update these values using more natural syntax
self.edgesConstraint.insets(UIEdgeInsetsMake(20, 10, 15, 5));
can now be written as:
self.edgesConstraint.insets = UIEdgeInsetsMake(20, 10, 15, 5);
[@[view1, view2, view3] mas_makeConstraints:^(MASConstraintMaker *make) {
make.baseline.equalTo(superView.mas_centerY);
make.width.equalTo(@100);
}];
- (NSArray *)mas_updateConstraints:(void(^)(MASConstraintMaker *))block
which will update existing constraints if possible, otherwise it will add them. This makes it easier to use Masonry within the UIView
- (void)updateConstraints
method which is the recommended place for adding/updating constraints by apple.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。