Skip to content

Commit

Permalink
Merge pull request Tencent#228 from wanhmr/master
Browse files Browse the repository at this point in the history
Fixed 当使用 xib / storyboard 时,button 和 label 的大小展示错误
  • Loading branch information
zhoon authored Nov 9, 2017
2 parents 6782c71 + 75d1e1d commit ca92e3b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions QMUIKit/QMUIComponents/QMUIButton.m
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ - (CGSize)sizeThatFits:(CGSize)size {
return resultSize;
}

- (CGSize)intrinsicContentSize {
return [self sizeThatFits:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)];
}

- (void)layoutSubviews {
[super layoutSubviews];

Expand Down
8 changes: 8 additions & 0 deletions QMUIKit/QMUIComponents/QMUILabel.m
Original file line number Diff line number Diff line change
Expand Up @@ -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)];
}
Expand Down

0 comments on commit ca92e3b

Please sign in to comment.