Skip to content

Commit

Permalink
增加头部昵称 修改时间显示
Browse files Browse the repository at this point in the history
  • Loading branch information
anyunzhong committed Oct 5, 2015
1 parent 4f34cf0 commit 3d63477
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#import "DFLineLikeItem.h"
#import "DFLineCommentItem.h"
#import "UIImageView+WebCache.h"
#import <MLLabel+Size.h>



Expand All @@ -25,6 +26,9 @@
#define AvatarRightMargin 15
#define AvatarPadding 2


#define NickFont [UIFont systemFontOfSize:20]

@interface DFTimeLineViewController ()<DFLineCellDelegate>

@property (nonatomic, strong) NSMutableArray *items;
Expand All @@ -35,6 +39,8 @@ @interface DFTimeLineViewController ()<DFLineCellDelegate>

@property (nonatomic, strong) UIImageView *userAvatar;

@property (nonatomic, strong) MLLabel *userNick;

@property (strong, nonatomic) UIRefreshControl *refreshControl;

@property (nonatomic, strong) UIView *footer;
Expand Down Expand Up @@ -133,14 +139,36 @@ -(void) initHeader
[avatarBg addSubview:_userAvatar];
[_userAvatar sd_setImageWithURL:[NSURL URLWithString:[self getAvatarUrl:width*2 height:height*2]]];

//用户昵称
if (_userNick == nil) {
NSString *nick = [self getUserNick];
if (nick != nil) {
CGSize size = [MLLabel getViewSizeByString:nick font:NickFont];
width = size.width;
height = size.height;
x = CGRectGetMinX(avatarBg.frame) - width - 5;
y = CGRectGetMidY(avatarBg.frame) - height - 2;
_userNick = [[MLLabel alloc] initWithFrame:CGRectMake(x, y, width, height)];
_userNick.textColor = [UIColor whiteColor];
_userNick.text = nick;
_userNick.font = NickFont;
_userNick.numberOfLines = 1;
_userNick.adjustsFontSizeToFitWidth = NO;
_userNick.textInsets = UIEdgeInsetsZero;

[header addSubview:_userNick];
}

}


//下来刷新
//下拉刷新
if (_refreshControl == nil) {
_refreshControl = [[UIRefreshControl alloc] init];
[_refreshControl addTarget:self action:@selector(onPullDown:) forControlEvents:UIControlEventValueChanged];
[_tableView addSubview:self.refreshControl];
}



}
Expand Down Expand Up @@ -313,7 +341,7 @@ -(void) showFooter




}


Expand All @@ -333,7 +361,7 @@ -(void) hideFooter
_tableView.tableFooterView = _footer;

_isLoadingMore = NO;

}];

}
Expand Down Expand Up @@ -383,6 +411,13 @@ -(NSString *) getAvatarUrl:(CGFloat) width height:(CGFloat) height
}



-(NSString *) getUserNick
{
return nil;
}


-(void) genLikeAttrString:(DFBaseLineItem *) item
{
if (item.likes.count == 0) {
Expand Down
3 changes: 3 additions & 0 deletions DFTimelineView/DFTimelineView/Item/DFBaseLineItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ typedef NS_ENUM(NSUInteger, LineItemType){

@property (nonatomic, strong) NSString *location;

@property (nonatomic, assign) long long ts;


@property (nonatomic, strong) NSMutableArray *likes;
@property (nonatomic, strong) NSMutableArray *comments;

Expand Down
3 changes: 2 additions & 1 deletion DFTimelineView/DFTimelineView/View/DFBaseLineCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#import <MLLabel+Size.h>
#import "DFLikeCommentView.h"
#import "DFLikeCommentToolbar.h"
#import <DFToolUtil.h>


@interface DFBaseLineCell()<DFLikeCommentToolbarDelegate, DFLikeCommentViewDelegate>
Expand Down Expand Up @@ -277,7 +278,7 @@ -(void) updateLocationLikeComment:(CGFloat)height
height = TimeLabelHeight;
_timeLabel.hidden = NO;
_timeLabel.frame = CGRectMake(x, y, width, height);
_timeLabel.text = @"昨天";
_timeLabel.text = [DFToolUtil preettyTime:self.item.ts];


//点赞评论按钮
Expand Down
7 changes: 7 additions & 0 deletions DFTimelineView/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ -(void) initData
textImageItem.thumbImages = thumbImages;

textImageItem.location = @"中国 • 广州";
textImageItem.ts = [[NSDate date] timeIntervalSince1970]*1000;


DFLineLikeItem *likeItem1_1 = [[DFLineLikeItem alloc] init];
Expand Down Expand Up @@ -244,6 +245,12 @@ -(NSString *) getAvatarUrl:(CGFloat) width height:(CGFloat) height



-(NSString *) getUserNick
{
return @"Allen";
}


-(void) refresh
{
//下来刷新
Expand Down

0 comments on commit 3d63477

Please sign in to comment.