IVTGreatHallViewController.m
5.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
//
// IVTGreatHallViewController.m
// IVTMeLiveTwo
//
// Created by XRG on 16/8/10.
// Copyright © 2016年 QLQ. All rights reserved.
//
#import "IVTGreatHallViewController.h"
#import "IVTMyChatListViewController.h"
#import "IVTMeSearchViewController.h"
#import "DBManager.h"
@interface IVTGreatHallViewController ()
{
GMCategaryScrollBar *scrb;
UIImageView *dot;
}
@end
@implementation IVTGreatHallViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self initUI];
[self setNavigationBar];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refreshDot) name:kPrivateMessageDidChange object:nil];
}
- (void)setNavigationBar{
[self hiddenLeftBarBackButtonItem];
[self setTitleText:@"大厅" textColor:UIColorFromRGBAlphaHex(0xf6f6f6, 1.0) textFont:[UIFont IVTH1Font]];
[self setCustomNavigationBarToSearchFunc];
[self setCustomNavigationBarToMessageFunc];
}
- (void)setTitleText:(NSString *)TitleText textColor:(UIColor *)textColor textFont:(UIFont *)textFont
{
[self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName: textColor,NSFontAttributeName:textFont}];
self.title = TitleText;
}
- (void)setCustomNavigationBarToSearchFunc{
UIBarButtonItem *leftBarButton = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"搜索图标"] style:UIBarButtonItemStylePlain target:self action:@selector(pushToSearchVCFunc)];
leftBarButton.tintColor = [UIColor whiteColor];
self.navigationItem.leftBarButtonItem = leftBarButton;
}
- (void)setCustomNavigationBarToMessageFunc
{
UIView *rightView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 30, 30)];
UIButton *messageButton = [UIButton buttonWithType:UIButtonTypeCustom];
messageButton.frame = rightView.frame;
[messageButton setImage:[UIImage imageNamed:@"进入私信"] forState:UIControlStateNormal];
[messageButton addTarget:self action:@selector(pushToMessageVCFunc) forControlEvents:UIControlEventTouchUpInside];
[rightView addSubview:messageButton];
dot = [[UIImageView alloc]initWithFrame:CGRectMake(23, 5, 4, 4)];
dot.backgroundColor = [UIColor whiteColor];
dot.userInteractionEnabled = YES;
dot.layer.cornerRadius = 2;
dot.clipsToBounds = YES;
[rightView addSubview:dot];
if ([[DBManager sharedInstance] getTotalNumberOfMessageNoRead] > 0) {
dot.hidden = NO;
}
else{
dot.hidden = YES;
}
UIBarButtonItem *rightBarButton = [[UIBarButtonItem alloc]initWithCustomView:rightView];
self.navigationItem.rightBarButtonItem = rightBarButton;
}
- (void)refreshDot{
NSInteger total = [[DBManager sharedInstance] getTotalNumberOfMessageNoRead];
dispatch_async(dispatch_get_main_queue(), ^{
if (total > 0) {
dot.hidden = NO;
}
else{
dot.hidden = YES;
}
});
}
- (void)pushToSearchVCFunc
{
IVTMeSearchViewController *meSearchVC = [[IVTMeSearchViewController alloc]init];
meSearchVC.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:meSearchVC animated:YES];
}
- (void)pushToMessageVCFunc
{
IVTMyChatListViewController *myChatListVC = [[IVTMyChatListViewController alloc]init];
myChatListVC.isSmall = NO;
myChatListVC.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:myChatListVC animated:YES];
}
- (void)initUI{
NSMutableArray *ary = [NSMutableArray arrayWithArray:@[@"关注",@"热门",@"最新",@"明星"]];
scrb = [GMCategaryScrollBar categaryScrollBar];
scrb.scrv.contentInset = UIEdgeInsetsZero;
scrb.scrv.scrollIndicatorInsets = UIEdgeInsetsZero;
scrb.isReponseDelegate = YES;
[scrb categaryBarTitle:ary withIsEqualBtn:YES];
[self.view addSubview:scrb];
NSArray *aryType = @[@"attention",@"hot",@"new",@"star"];
// 组装VC
NSMutableArray *maryVC = [NSMutableArray array];
for (NSInteger i = 0; i < ary.count; i++)
{
if (i == 0 || i == 1) {
IVTHotAndFollowLiveVC *hotVC = [[IVTHotAndFollowLiveVC alloc] init];
[hotVC.tableV reloadData];
hotVC.strType = aryType[i];
[maryVC addObject:hotVC];
[self addChildViewController:hotVC];
}else if (i == 2){
IVTNewLiveVC *newVC = [[IVTNewLiveVC alloc] init];
[newVC.userLiveScrollView reloadData];
newVC.strType = aryType[2];
[maryVC addObject:newVC];
[self addChildViewController:newVC];
}else if (i ==3){
IVTStarLiveVC *starVC = [[IVTStarLiveVC alloc] init];
[starVC.userLiveScrollView reloadData];
[starVC.tableV reloadData];
starVC.strType = aryType[3];
[maryVC addObject:starVC];
[self addChildViewController:starVC];
}
}
scrb.maryVC = maryVC;
[scrb automaticScroll:1];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end