Use reference cells for measurement.

// FREEBIE
pull/1/head
Matthew Chen 9 years ago
parent 91af4f93e1
commit 83b03c0047

@ -261,10 +261,7 @@ NS_ASSUME_NONNULL_BEGIN
result.height += self.topVMargin; result.height += self.topVMargin;
result.height += self.bottomVMargin; result.height += self.bottomVMargin;
self.titleLabel.font = [self titleFont];
[self applyTitleForInteraction:interaction label:self.titleLabel]; [self applyTitleForInteraction:interaction label:self.titleLabel];
self.titleLabel.numberOfLines = 0;
self.titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
CGFloat maxTitleWidth = (collectionViewWidth - ([self hMargin] * 2.f + [self hSpacing] + [self iconSize])); CGFloat maxTitleWidth = (collectionViewWidth - ([self hMargin] * 2.f + [self hSpacing] + [self iconSize]));
CGSize titleSize = [self.titleLabel sizeThatFits:CGSizeMake(maxTitleWidth, CGFLOAT_MAX)]; CGSize titleSize = [self.titleLabel sizeThatFits:CGSizeMake(maxTitleWidth, CGFLOAT_MAX)];
CGFloat contentHeight = ceil(MAX([self iconSize], titleSize.height)); CGFloat contentHeight = ceil(MAX([self iconSize], titleSize.height));

@ -75,13 +75,11 @@ NS_ASSUME_NONNULL_BEGIN
[self.bannerView addSubview:self.bannerBottomHighlightView2]; [self.bannerView addSubview:self.bannerBottomHighlightView2];
self.titleLabel = [UILabel new]; self.titleLabel = [UILabel new];
self.titleLabel.text = [self titleForInteraction:self.interaction];
self.titleLabel.textColor = [UIColor colorWithRGBHex:0x403e3b]; self.titleLabel.textColor = [UIColor colorWithRGBHex:0x403e3b];
self.titleLabel.font = [self titleFont]; self.titleLabel.font = [self titleFont];
[self.bannerView addSubview:self.titleLabel]; [self.bannerView addSubview:self.titleLabel];
self.subtitleLabel = [UILabel new]; self.subtitleLabel = [UILabel new];
self.subtitleLabel.text = [self subtitleForInteraction:self.interaction];
self.subtitleLabel.textColor = [UIColor ows_infoMessageBorderColor]; self.subtitleLabel.textColor = [UIColor ows_infoMessageBorderColor];
self.subtitleLabel.font = [self subtitleFont]; self.subtitleLabel.font = [self subtitleFont];
self.subtitleLabel.numberOfLines = 0; self.subtitleLabel.numberOfLines = 0;
@ -101,6 +99,9 @@ NS_ASSUME_NONNULL_BEGIN
_interaction = interaction; _interaction = interaction;
self.titleLabel.text = [self titleForInteraction:self.interaction];
self.subtitleLabel.text = [self subtitleForInteraction:self.interaction];
self.backgroundColor = [UIColor whiteColor]; self.backgroundColor = [UIColor whiteColor];
[self setNeedsLayout]; [self setNeedsLayout];
@ -225,6 +226,7 @@ NS_ASSUME_NONNULL_BEGIN
UILabel *label = self.titleLabel; UILabel *label = self.titleLabel;
label.font = [self titleFont]; label.font = [self titleFont];
label.text = title; label.text = title;
label.numberOfLines = 1;
result.height += ceil([label sizeThatFits:CGSizeZero].height); result.height += ceil([label sizeThatFits:CGSizeZero].height);
if (subtitle.length > 0) { if (subtitle.length > 0) {

Loading…
Cancel
Save