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 a68bde2

Browse files
私信语音背景方向问题 & 时间天数判断问题
1 parent 0ddf7eb commit a68bde2

File tree

2 files changed

+18
-28
lines changed

2 files changed

+18
-28
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,13 @@ - (NSInteger)yearsAgo{
5959
}
6060

6161
- (NSInteger)leftDayCount{
62-
return [self day] - [[NSDate date] day];
62+
NSDate *today = [NSDate dateFromString:[[NSDate date] stringWithFormat:@"yyyy-MM-dd"] withFormat:@"yyyy-MM-dd"];//时分清零
63+
NSCalendar *calendar = [[self class] sharedCalendar];
64+
NSDateComponents *components = [calendar components:(NSDayCalendarUnit)
65+
fromDate:today
66+
toDate:self
67+
options:0];
68+
return [components day];
6369
}
6470

6571
- (NSString *)stringTimesAgo{

‎Coding_iOS/Views/Cell/MessageCell.m

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
6666
_contentLabel = [[UITTTAttributedLabel alloc] initWithFrame:CGRectMake(kMessageCell_PadingWidth, kMessageCell_PadingHeight, 0, 0)];
6767
_contentLabel.numberOfLines = 0;
6868
_contentLabel.font =kMessageCell_FontContent;
69+
_contentLabel.textColor = [UIColor blackColor];
6970
_contentLabel.backgroundColor = [UIColor clearColor];
7071
_contentLabel.linkAttributes = kLinkAttributes;
7172
_contentLabel.activeLinkAttributes = kLinkAttributesActive;
@@ -100,6 +101,7 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
100101

101102
- (void)setCurPriMsg:(PrivateMessage *)curPriMsg andPrePriMsg:(PrivateMessage *)prePriMsg{
102103
CGFloat mediaViewHeight = [MessageCell mediaViewHeightWithObj:curPriMsg];
104+
BOOL isMyMsg = [curPriMsg.sender.global_key isEqualToString:[Login curLoginUser].global_key];
103105

104106
if (_curPriMsg == curPriMsg && _prePriMsg == prePriMsg && _preMediaViewHeight == mediaViewHeight) {
105107
[self configSendStatus];
@@ -111,13 +113,7 @@ - (void)setCurPriMsg:(PrivateMessage *)curPriMsg andPrePriMsg:(PrivateMessage *)
111113
else {
112114
[_voiceView setUrl:[NSURL fileURLWithPath:curPriMsg.voiceMedia.file]];
113115
}
114-
115-
if ([_curPriMsg.sender.global_key isEqualToString:[Login curLoginUser].global_key]) {
116-
_voiceView.isUnread = NO;
117-
}
118-
else {
119-
_voiceView.isUnread = curPriMsg.played.intValue == 0;
120-
}
116+
_voiceView.isUnread = !isMyMsg && (curPriMsg.played.intValue == 0);
121117
}
122118
return;
123119
}else{
@@ -194,13 +190,7 @@ - (void)setCurPriMsg:(PrivateMessage *)curPriMsg andPrePriMsg:(PrivateMessage *)
194190
[_voiceView setUrl:[NSURL fileURLWithPath:curPriMsg.voiceMedia.file]];
195191
_voiceView.duration = curPriMsg.voiceMedia.duration;
196192
}
197-
198-
if ([_curPriMsg.sender.global_key isEqualToString:[Login curLoginUser].global_key]) {
199-
_voiceView.isUnread = NO;
200-
}
201-
else {
202-
_voiceView.isUnread = curPriMsg.played.intValue == 0;
203-
}
193+
_voiceView.isUnread = !isMyMsg && (curPriMsg.played.intValue == 0);
204194

205195
_voiceView.playStartedBlock = ^(AudioPlayView *view) {
206196
BubblePlayView *bubbleView = (BubblePlayView *)view;
@@ -211,32 +201,26 @@ - (void)setCurPriMsg:(PrivateMessage *)curPriMsg andPrePriMsg:(PrivateMessage *)
211201
}
212202
};
213203
bgImgViewSize = CGSizeMake(_voiceView.frame.size.width, 40);
204+
_voiceView.type = isMyMsg? BubbleTypeRight: BubbleTypeLeft;
214205
}
215206

216207
CGRect bgImgViewFrame;
217-
if (![_curPriMsg.sender.global_key isEqualToString:[Login curLoginUser].global_key]) {
208+
if (!isMyMsg) {
218209
// 这是好友发的
219210
bgImgViewFrame = CGRectMake(kPaddingLeftWidth +kMessageCell_UserIconWith, curBottomY +kMessageCell_PadingHeight, bgImgViewSize.width, bgImgViewSize.height);
220211
[_userIconView setCenter:CGPointMake(kPaddingLeftWidth +kMessageCell_UserIconWith/2, CGRectGetMaxY(bgImgViewFrame)- kMessageCell_UserIconWith/2)];
221-
bgImg = [UIImage imageNamed:@"messageLeft_bg_img"];
222-
223-
bgImg = [bgImg resizableImageWithCapInsets:UIEdgeInsetsMake(18, 30, bgImg.size.height - 19, bgImg.size.width - 31)];
224-
_contentLabel.textColor = [UIColor blackColor];
225212
_bgImgView.frame = bgImgViewFrame;
226213
}else{
227214
// 这是自己发的
228215
bgImgViewFrame = CGRectMake((kScreen_Width - kPaddingLeftWidth - kMessageCell_UserIconWith) -bgImgViewSize.width, curBottomY +kMessageCell_PadingHeight, bgImgViewSize.width, bgImgViewSize.height);
229216
[_userIconView setCenter:CGPointMake(kScreen_Width - kPaddingLeftWidth -kMessageCell_UserIconWith/2, CGRectGetMaxY(bgImgViewFrame)- kMessageCell_UserIconWith/2)];
230-
bgImg = [UIImage imageNamed:@"messageRight_bg_img"];
231-
bgImg = [bgImg resizableImageWithCapInsets:UIEdgeInsetsMake(18, 30, bgImg.size.height - 19, bgImg.size.width - 31)];
232-
_contentLabel.textColor = [UIColor blackColor];
233217
_bgImgView.frame = bgImgViewFrame;
234218
}
235-
if (_voiceView
236-
|| [_curPriMsg isSingleBigMonkey]
237-
) {
238-
bgImg = nil; //使用bubbleView的背景
239-
_voiceView.type = BubbleTypeRight;
219+
if (_voiceView || [_curPriMsg isSingleBigMonkey] ) {
220+
bgImg = nil;
221+
}else{
222+
bgImg = [UIImage imageNamed:isMyMsg? @"messageRight_bg_img": @"messageLeft_bg_img"];
223+
bgImg = [bgImg resizableImageWithCapInsets:UIEdgeInsetsMake(18, 30, bgImg.size.height - 19, bgImg.size.width - 31)];
240224
}
241225

242226
__weak typeof(self) weakSelf = self;

0 commit comments

Comments
(0)

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