Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 308cd6b

Browse files
优化冒泡页面的显示(行距) & 跟进一下 TTTAttributedLabel 的版本
1 parent 78e4496 commit 308cd6b

File tree

7 files changed

+31
-19
lines changed

7 files changed

+31
-19
lines changed

‎Coding_iOS/Controllers/Login/RegisterViewController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ - (UIView *)customFooterView{
253253
}];
254254
//label
255255
UITTTAttributedLabel *lineLabel = ({
256-
UITTTAttributedLabel *label = [[UITTTAttributedLabel alloc] init];
256+
UITTTAttributedLabel *label = [[UITTTAttributedLabel alloc] initWithFrame:CGRectZero];
257257
label.textAlignment = NSTextAlignmentCenter;
258258
label.font = [UIFont systemFontOfSize:14];
259259
label.textColor = kColorDark2;

‎Coding_iOS/Util/OC_Category/UILabel+Common.m

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,12 @@ - (void)setLongString:(NSString *)str withFitWidth:(CGFloat)width{
1515

1616
- (void) setLongString:(NSString *)str withFitWidth:(CGFloat)width maxHeight:(CGFloat)maxHeight{
1717
self.numberOfLines = 0;
18-
CGSize resultSize = [str getSizeWithFont:self.font constrainedToSize:CGSizeMake(width, CGFLOAT_MAX)];
19-
CGFloat resultHeight = resultSize.height;
20-
if (maxHeight > 0 && resultHeight > maxHeight) {
21-
resultHeight = maxHeight;
22-
}
23-
CGRect frame = self.frame;
24-
frame.size.height = resultHeight;
25-
[self setFrame:frame];
2618
self.text = str;
19+
CGSize resultSize = [self sizeThatFits:CGSizeMake(width, maxHeight)];
20+
if (maxHeight > 0 && resultSize.height > maxHeight) {
21+
resultSize.height = maxHeight;
22+
}
23+
self.size = resultSize;
2724
}
2825

2926
- (void) setLongString:(NSString *)str withVariableWidth:(CGFloat)maxWidth{

‎Coding_iOS/Views/Cell/ProjectInfoCell.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
4949
[self.contentView addSubview:_proTitleL];
5050
}
5151
if (!_proInfoL) {
52-
_proInfoL = [[UITTTAttributedLabel alloc] init];
52+
_proInfoL = [[UITTTAttributedLabel alloc] initWithFrame:CGRectZero];
5353
_proInfoL.delegate = self;
5454
_proInfoL.linkAttributes = kLinkAttributes;
5555
_proInfoL.activeLinkAttributes = kLinkAttributesActive;

‎Coding_iOS/Views/Cell/TweetCell.m

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
9898
self.contentLabel.font = kTweet_ContentFont;
9999
self.contentLabel.textColor = kColorDark3;
100100
self.contentLabel.numberOfLines = 0;
101-
101+
self.contentLabel.lineHeightMultiple = 1.2;
102+
102103
self.contentLabel.linkAttributes = kLinkAttributes;
103104
self.contentLabel.activeLinkAttributes = kLinkAttributesActive;
104105
self.contentLabel.delegate = self;
@@ -377,9 +378,23 @@ + (CGFloat)cellHeightWithObj:(id)obj needTopView:(BOOL)needTopView{
377378

378379
+ (CGFloat)contentLabelHeightWithTweet:(Tweet *)tweet{
379380
CGFloat height = 0;
381+
// if (tweet.content.length > 0) {
382+
// height += MIN(kTweet_ContentMaxHeight, [tweet.content getHeightWithFont:kTweet_ContentFont constrainedToSize:CGSizeMake(kTweetCell_ContentWidth, CGFLOAT_MAX)]);
383+
// height += 15;
384+
// }
385+
static UITTTAttributedLabel *p_contentLabel = nil;
380386
if (tweet.content.length > 0) {
381-
height += MIN(kTweet_ContentMaxHeight, [tweet.content getHeightWithFont:kTweet_ContentFont constrainedToSize:CGSizeMake(kTweetCell_ContentWidth, CGFLOAT_MAX)]);
382-
height += 15;
387+
if (!p_contentLabel) {
388+
p_contentLabel = [[UITTTAttributedLabel alloc] initWithFrame:CGRectMake(kTweetCell_PadingLeft, kTweetCell_PadingTop, kTweetCell_ContentWidth, 20)];
389+
p_contentLabel.font = kTweet_ContentFont;
390+
p_contentLabel.textColor = kColorDark3;
391+
p_contentLabel.numberOfLines = 0;
392+
p_contentLabel.lineHeightMultiple = 1.2;
393+
p_contentLabel.linkAttributes = kLinkAttributes;
394+
p_contentLabel.activeLinkAttributes = kLinkAttributesActive;
395+
}
396+
[p_contentLabel setLongString:tweet.content withFitWidth:kTweetCell_ContentWidth maxHeight:kTweet_ContentMaxHeight];
397+
height += p_contentLabel.height + 15;
383398
}
384399
return height;
385400
}

‎Coding_iOS/Views/Cell/TweetCommentCell.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
#define kTweetCommentCell_LeftOrRightPading 10.0
1313
#define kTweetCommentCell_ContentWidth (kScreen_Width -kPaddingLeftWidth - kPaddingLeftWidth - 2*kTweetCommentCell_LeftOrRightPading)
14-
#define kTweetCommentCell_ContentMaxHeight 105.0
14+
#define kTweetCommentCell_ContentMaxHeight 150.0
1515

1616
#import "TweetCommentCell.h"
1717

‎Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ platform :ios, '9.0'
33

44
target "Coding_iOS" do
55

6-
pod 'TTTAttributedLabel', '1.10.1'
6+
pod 'TTTAttributedLabel', '2.0.0'
77
pod 'RegexKitLite-NoWarning', '1.1.0'
88
pod 'hpple', '0.2.0'
99
pod 'MBProgressHUD', '0.9'

‎Podfile.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ PODS:
6767
- SSKeychain (1.2.3)
6868
- TMCache (2.1.0)
6969
- TPKeyboardAvoiding (1.2.4)
70-
- TTTAttributedLabel (1.10.1)
70+
- TTTAttributedLabel (2.0.0)
7171
- "UIImage+BlurredFrame (0.0.4)"
7272
- UMengAnalytics (4.2.4)
7373
- UMengUShare/Core (6.4.5):
@@ -111,7 +111,7 @@ DEPENDENCIES:
111111
- SSKeychain (= 1.2.3)
112112
- TMCache (= 2.1.0)
113113
- TPKeyboardAvoiding (= 1.2.4)
114-
- TTTAttributedLabel (= 1.10.1)
114+
- TTTAttributedLabel (= 2.0.0)
115115
- "UIImage+BlurredFrame (= 0.0.4)"
116116
- UMengAnalytics (= 4.2.4)
117117
- UMengUShare/Social/QQ (= 6.4.5)
@@ -182,11 +182,11 @@ SPEC CHECKSUMS:
182182
SSKeychain: 3f42991739c6c60a9cf1bbd4dff6c0d3694bcf3d
183183
TMCache: 95ebcc9b3c7e90fb5fd8fc3036cba3aa781c9bed
184184
TPKeyboardAvoiding: 0a40dfbb0af7c8bdae1dd457496dccfd217d85f6
185-
TTTAttributedLabel: c8f3801a6463b9c9b82b0c84c465fdda9751892a
185+
TTTAttributedLabel: 8cffe8e127e4e82ff3af1e5386d4cd0ad000b656
186186
"UIImage+BlurredFrame": ad2f7195c6947ea3117c7d202f75a51958d5061a
187187
UMengAnalytics: ef8d45f94c0e5771dc364cf6a5731d9d3b101da2
188188
UMengUShare: a5711c54e640b04e3048e931d2b88d50f9cfa55c
189189

190-
PODFILE CHECKSUM: 4e7599df566b810cb65e8505f699da5ada302db4
190+
PODFILE CHECKSUM: 36e1606f3eaec7aedeba960c5747dba1ea4490d1
191191

192192
COCOAPODS: 1.5.0

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /