diff --git a/QMUIKit/QMUIComponents/QMUIButton.m b/QMUIKit/QMUIComponents/QMUIButton.m index f7ec0c31..ca69bfb4 100644 --- a/QMUIKit/QMUIComponents/QMUIButton.m +++ b/QMUIKit/QMUIComponents/QMUIButton.m @@ -128,6 +128,10 @@ - (CGSize)sizeThatFits:(CGSize)size { return resultSize; } +- (CGSize)intrinsicContentSize { + return [self sizeThatFits:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)]; +} + - (void)layoutSubviews { [super layoutSubviews]; diff --git a/QMUIKit/QMUIComponents/QMUILabel.m b/QMUIKit/QMUIComponents/QMUILabel.m index 3875568a..82bdc0e7 100644 --- a/QMUIKit/QMUIComponents/QMUILabel.m +++ b/QMUIKit/QMUIComponents/QMUILabel.m @@ -34,6 +34,14 @@ - (CGSize)sizeThatFits:(CGSize)size { return size; } +- (CGSize)intrinsicContentSize { + CGFloat preferredMaxLayoutWidth = self.preferredMaxLayoutWidth; + if (preferredMaxLayoutWidth <= 0) { + preferredMaxLayoutWidth = CGFLOAT_MAX; + } + return [self sizeThatFits:CGSizeMake(preferredMaxLayoutWidth, CGFLOAT_MAX)]; +} + - (void)drawTextInRect:(CGRect)rect { return [super drawTextInRect:UIEdgeInsetsInsetRect(rect, self.contentEdgeInsets)]; }