summaryrefslogtreecommitdiff
path: root/Juick
diff options
context:
space:
mode:
Diffstat (limited to 'Juick')
-rw-r--r--Juick/MessageCell.h1
-rw-r--r--Juick/MessageCell.m11
-rw-r--r--Juick/UILabel+Utils.h15
-rw-r--r--Juick/UILabel+Utils.m16
4 files changed, 36 insertions, 7 deletions
diff --git a/Juick/MessageCell.h b/Juick/MessageCell.h
index a042ff3..75d46cf 100644
--- a/Juick/MessageCell.h
+++ b/Juick/MessageCell.h
@@ -14,6 +14,7 @@
#import "NSString+HTML.h"
#import "UIImage+Utils.h"
+#import "UILabel+Utils.h"
#define kLabelHorizontalInsets 20.0f
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;
diff --git a/Juick/UILabel+Utils.h b/Juick/UILabel+Utils.h
new file mode 100644
index 0000000..2e9cbb6
--- /dev/null
+++ b/Juick/UILabel+Utils.h
@@ -0,0 +1,15 @@
+//
+// UILabel+Utils.h
+// Juick
+//
+// Created by Vitaly on 01.02.14.
+// Copyright (c) 2014 com.juick. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface UILabel (Utils)
+
++ (CGRect) sizeForLabel:(UILabel *)label width:(CGFloat)width;
+
+@end
diff --git a/Juick/UILabel+Utils.m b/Juick/UILabel+Utils.m
new file mode 100644
index 0000000..91136d0
--- /dev/null
+++ b/Juick/UILabel+Utils.m
@@ -0,0 +1,16 @@
+//
+// UILabel+Utils.m
+// Juick
+//
+// Created by Vitaly on 01.02.14.
+// Copyright (c) 2014 com.juick. All rights reserved.
+//
+
+#import "UILabel+Utils.h"
+
+@implementation UILabel (Utils)
+
++ (CGRect) sizeForLabel:(UILabel *)label width:(CGFloat)width {
+ return [label.text boundingRectWithSize:(CGSize) {width, CGFLOAT_MAX} options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:label.font} context:nil];
+}
+@end