Masonry 原理与使用说明
原理:
1)約束生成;MASConstraintMaker;
2)缺省補(bǔ)齊:
- (void)setSecondViewAttribute:(id)secondViewAttribute {
? ? if ([secondViewAttribute isKindOfClass:NSValue.class]) {
? ? ? ? [self setLayoutConstantWithValue:secondViewAttribute];
? ? } else if ([secondViewAttribute isKindOfClass:MAS_VIEW.class]) {
? ? ? ? _secondViewAttribute = [[MASViewAttribute alloc] initWithView:secondViewAttribute layoutAttribute:self.firstViewAttribute.layoutAttribute];
? ? } else if ([secondViewAttribute isKindOfClass:MASViewAttribute.class]) {
? ? ? ? _secondViewAttribute = secondViewAttribute;
? ? } else {
? ? ? ? NSAssert(NO, @"attempting to add unsupported attribute: %@", secondViewAttribute);
? ? }
}
3)尋找約束添加視圖,并添加
? ??if (self.secondViewAttribute.view) {
? ? ? ? MAS_VIEW *closestCommonSuperview = [self.firstViewAttribute.view mas_closestCommonSuperview:self.secondViewAttribute.view];
? ? ? ? NSAssert(closestCommonSuperview,
?? ? ? ? ? ? ? ? @"couldn't find a common superview for %@ and %@",
?? ? ? ? ? ? ? ? self.firstViewAttribute.view, self.secondViewAttribute.view);
? ? ? ? self.installedView = closestCommonSuperview;
? ? } else if (self.firstViewAttribute.isSizeAttribute) {
? ? ? ? self.installedView = self.firstViewAttribute.view;
? ? } else {
? ? ? ? self.installedView = self.firstViewAttribute.view.superview;
? ? }
4)
(1)絕對尺寸信息添加到自身;
(2)絕對布局?jǐn)?shù)據(jù)添加到父視圖;
(3)參考系屬性缺失補(bǔ)全為目標(biāo)屬性。
?
總結(jié)
以上是生活随笔為你收集整理的Masonry 原理与使用说明的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Hive权限与HDFS权限分离导致的一些
- 下一篇: 烂泥:为KVM虚拟机添加网卡