From 50a0ecf985bbe81aacfac85192652c2495b769f6 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sat, 1 Feb 2014 20:17:24 +0400 Subject: move UILabel sizeForLabel to category --- Juick/MessageCell.m | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'Juick/MessageCell.m') diff --git a/Juick/MessageCell.m b/Juick/MessageCell.m index 8c2f001..d2b2983 100644 --- a/Juick/MessageCell.m +++ b/Juick/MessageCell.m @@ -80,31 +80,28 @@ // Configure the view for the selected state } -- (CGRect) sizeForLabel:(UILabel *)label width:(CGFloat)width { - return [label.text boundingRectWithSize:(CGSize) {width, CGFLOAT_MAX} options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:label.font} context:nil]; -} - (CGRect) avatarRect { return CGRectMake(kPaddingX, kPaddingY, kAvatarSizeX, kAvatarSizeY); } - (CGRect) bodyRect { - CGRect bodySize = [self sizeForLabel:self.bodyLabel width:(self.contentView.bounds.size.width - kPaddingX * 2)]; + CGRect bodySize = [UILabel sizeForLabel:self.bodyLabel width:(self.contentView.bounds.size.width - kPaddingX * 2)]; return CGRectMake(kPaddingX, kPaddingY + kAvatarSizeY + kPaddingY * 2, bodySize.size.width, bodySize.size.height); } - (CGRect) titleRect { - CGRect titleSize = [self sizeForLabel:self.titleLabel width:self.contentView.bounds.size.width - [self avatarRect].size.width - kPaddingX * 2]; + CGRect titleSize = [UILabel sizeForLabel:self.titleLabel width:self.contentView.bounds.size.width - [self avatarRect].size.width - kPaddingX * 2]; return CGRectMake(kPaddingX + kAvatarSizeX + kPaddingX, kPaddingY, titleSize.size.width, titleSize.size.height); } - (CGRect) timestampRect { - CGRect timeStampSize = [self sizeForLabel:self.timestampLabel width:self.contentView.bounds.size.width - [self avatarRect].size.width - kPaddingX * 2]; + CGRect timeStampSize = [UILabel sizeForLabel:self.timestampLabel width:self.contentView.bounds.size.width - [self avatarRect].size.width - kPaddingX * 2]; return CGRectMake(kPaddingX + [self avatarRect].size.width + kPaddingX, kPaddingY + [self titleRect].size.height + kPaddingY, timeStampSize.size.width, timeStampSize.size.height); } - (CGRect) summaryRect { - CGRect summarySize = [self sizeForLabel:self.summaryLabel width:(self.contentView.bounds.size.width - 20)]; + CGRect summarySize = [UILabel sizeForLabel:self.summaryLabel width:(self.contentView.bounds.size.width - 20)]; float summaryY = 10 + 32 + 10 + [self bodyRect].size.height + 10; if (self.message.attach != nil) { summaryY += [self attachRect].size.height + 10; -- cgit v1.2.3