//
|
// commetHeaderView.m
|
// mgysVideo
|
//
|
// Created by weikou on 16/7/25.
|
// Copyright © 2016年 wgj. All rights reserved.
|
//
|
|
#import "commentHeaderView.h"
|
|
@implementation commentHeaderView
|
|
-(instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier{
|
if (self=[super initWithReuseIdentifier:reuseIdentifier]) {
|
self.contentView.backgroundColor=kGlobalBackgroundColor;
|
//分割线
|
UILabel *Splitline=[[UILabel alloc] initWithFrame:CGRectMake(0, 0, KScreenW, 0.5)];
|
Splitline.backgroundColor=KGlobalLightGreyColor_230;
|
[self.contentView addSubview:Splitline];
|
_Splitline=Splitline;
|
|
//创建回复评论用户的头像视图
|
UIImageView *headImage=[[UIImageView alloc] init];
|
headImage.frame=CGRectMake(5, 15, 40, 40);
|
|
//设置成圆形头像
|
headImage.layer.masksToBounds=YES;
|
headImage.layer.cornerRadius=20;
|
[self.contentView addSubview:headImage];
|
_headerImageView=headImage;
|
|
//创建回复评论用户的用户名
|
UILabel *username=[[UILabel alloc] init];
|
username.frame=CGRectMake(50, 20, KScreenW/2, 10);
|
username.font=[UIFont systemFontOfSize:14];
|
[self.contentView addSubview:username];
|
_userNameLabel=username;
|
|
//显示用户回复的时间
|
UILabel *commentTime=[[UILabel alloc] init];
|
commentTime.frame=CGRectMake(50, 35, KScreenW/2, 20);
|
commentTime.font=[UIFont systemFontOfSize:12];
|
[self.contentView addSubview:commentTime];
|
_commentTimeLabel=commentTime;
|
|
//用户的评论
|
UILabel *commentContentView=[[UILabel alloc] init];
|
commentContentView.frame=CGRectMake(50, 55, KScreenW-70, 0);
|
commentContentView.font=[UIFont systemFontOfSize:14];
|
commentContentView.numberOfLines=0;
|
commentContentView.lineBreakMode=NSLineBreakByTruncatingTail;
|
[self.contentView addSubview:commentContentView];
|
_commentContentLabel=commentContentView;
|
|
//举报功能
|
UIButton *ReportBtn=[[UIButton alloc] init];
|
ReportBtn.backgroundColor=[UIColor clearColor];
|
ReportBtn.frame=CGRectMake(KScreenW-115, 20, 50, 20);
|
[ReportBtn setTitle:@"举报" forState:UIControlStateNormal];
|
[ReportBtn setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
|
ReportBtn.titleLabel.font=[UIFont systemFontOfSize:14];
|
[ReportBtn addTarget:self action:@selector(ReportMessage) forControlEvents:UIControlEventTouchUpInside];
|
[self.contentView addSubview:ReportBtn];
|
_ReportButton=ReportBtn;
|
|
//设置点击回复的Button
|
UIButton *replyBtn=[[UIButton alloc] init];
|
replyBtn.backgroundColor=[UIColor clearColor];
|
replyBtn.frame=CGRectMake(KScreenW-75, 10, 50, 30);
|
[replyBtn setTitle:@"回复" forState:UIControlStateNormal];
|
[replyBtn setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
|
replyBtn.titleLabel.font=[UIFont systemFontOfSize:14];
|
|
[replyBtn addTarget:self action:@selector(replyMessage) forControlEvents:UIControlEventTouchUpInside];
|
[self.contentView addSubview:replyBtn];
|
_replyButton=replyBtn;
|
}
|
return self;
|
}
|
|
-(void)replyMessage{
|
NSLog(@"点击了回复,%d",[_section intValue]);
|
//添加 字典,将label的值通过key值设置传递
|
NSString *str=[NSString stringWithFormat:@"%d",[_section intValue]];
|
NSMutableDictionary *dict =[NSMutableDictionary dictionary];
|
[dict setObject:str forKey:@"replyMessage"];
|
[dict setObject:@"回复" forKey:@"replyType"];
|
//创建通知
|
NSNotification *notification =[NSNotification notificationWithName:@"reply" object:nil userInfo:dict];
|
//通过通知中心发送通知
|
[[NSNotificationCenter defaultCenter] postNotification:notification];
|
}
|
|
-(void)ReportMessage{
|
NSLog(@"点击了回复,%d",[_section intValue]);
|
//添加 字典,将label的值通过key值设置传递
|
NSString *str=[NSString stringWithFormat:@"%d",[_section intValue]];
|
NSMutableDictionary *dict =[NSMutableDictionary dictionary];
|
[dict setObject:str forKey:@"replyMessage"];
|
[dict setObject:@"举报" forKey:@"replyType"];
|
//创建通知
|
NSNotification *notification =[NSNotification notificationWithName:@"reply" object:nil userInfo:dict];
|
//通过通知中心发送通知
|
[[NSNotificationCenter defaultCenter] postNotification:notification];
|
|
}
|
|
+(instancetype)headerViewWithTableView:(UITableView*)tableView{
|
static NSString *sectionID=@"Header";
|
commentHeaderView *headerView=[tableView dequeueReusableHeaderFooterViewWithIdentifier:sectionID];
|
if (headerView==nil) {
|
headerView=[[commentHeaderView alloc] initWithReuseIdentifier:sectionID];
|
}
|
return headerView;
|
}
|
|
@end
|