13
13
14
14
@interface CSTopicHeaderView ()
15
15
@property (nonatomic ,strong )NSDictionary *refTopic;
16
- @property (nonatomic ,strong )UIButton *rightBtn;
16
+ // @property (nonatomic,strong)UIButton *rightBtn;
17
17
@property (nonatomic ,strong )NSMutableArray *avatalist;
18
18
@property (nonatomic ,assign )BOOL watched;
19
19
@end
20
20
21
21
@implementation CSTopicHeaderView {
22
- UILabel *_nameLabel;
22
+ // UILabel *_nameLabel;
23
23
UILabel *_userCountLabel;
24
24
}
25
25
26
26
- (id )initWithFrame : (CGRect )frame {
27
27
self = [super initWithFrame: frame];
28
28
if (self) {
29
- self.backgroundColor = [UIColor colorWithHexString: @" 0xeeeeee" ];
30
-
31
- // count区域
32
- _nameLabel = [[UILabel alloc ] initWithFrame: CGRectMake (12 , 12 , kScreen_Width - 110 , 18 )];// 12
33
- _nameLabel.font = [UIFont boldSystemFontOfSize: 15 ];
34
- _nameLabel.backgroundColor = [UIColor clearColor ];
35
- _nameLabel.textColor = [UIColor colorWithHexString: @" 0x222222" ];
36
- _nameLabel.textAlignment = NSTextAlignmentLeft;
37
- [self addSubview: _nameLabel];
38
-
39
- _userCountLabel = [[UILabel alloc ] initWithFrame: CGRectMake (12 , 36 , _nameLabel.width, 12 )];
40
- _userCountLabel.font = [UIFont systemFontOfSize: 12 ];
41
- _userCountLabel.backgroundColor = [UIColor clearColor ];
42
- _userCountLabel.textColor = [UIColor colorWithHexString: @" 0x999999" ];
43
- _userCountLabel.textAlignment = NSTextAlignmentLeft;
44
- [self addSubview: _userCountLabel];
45
-
46
- _rightBtn = [[UIButton alloc ] initWithFrame: CGRectMake (0 , 0 , 80 , 32 )];
47
- _rightBtn.centerY = 58 /2 ;
48
- _rightBtn.right = kScreen_Width - 13 ;
49
- [_rightBtn addTarget: self action: @selector (rightBtnClicked ) forControlEvents: UIControlEventTouchUpInside];
50
- [self addSubview: _rightBtn];
51
-
52
-
53
- // 头像区域
54
- UIView *subView = [[UIView alloc ] initWithFrame: CGRectMake (0 , 58 , kScreen_Width , 115 )];
55
- subView.backgroundColor = [UIColor whiteColor ];
56
- [self addSubview: subView];
29
+ self.backgroundColor = [UIColor whiteColor ];
30
+ self.clipsToBounds = YES ;
57
31
58
32
UIView *sepLine = [[UIView alloc ] initWithFrame: CGRectMake (12 , 41 , kScreen_Width - 12 , 0.5 )];
59
33
sepLine.backgroundColor = [UIColor colorWithHexString: @" 0xdddddd" ];
60
- [subView addSubview: sepLine];
34
+ [self addSubview: sepLine];
61
35
62
- UILabel *label1 = [[UILabel alloc ] initWithFrame: CGRectMake (12 , 15 , 150 , 15 )];
63
- label1.font = [UIFont systemFontOfSize: 13 ];
64
- label1.backgroundColor = [UIColor clearColor ];
65
- label1.textColor = [UIColor colorWithHexString: @" 0x333333" ];
66
- label1.textAlignment = NSTextAlignmentLeft;
67
- label1.text = @" 热门参与者" ;
68
- [subView addSubview: label1];
36
+ _userCountLabel = ({
37
+ UILabel *label1 = [[UILabel alloc ] initWithFrame: CGRectMake (12 , 15 , 150 , 15 )];
38
+ label1.font = [UIFont systemFontOfSize: 13 ];
39
+ label1.backgroundColor = [UIColor clearColor ];
40
+ label1.textColor = [UIColor colorWithHexString: @" 0x333333" ];
41
+ label1.textAlignment = NSTextAlignmentLeft;
42
+ [self addSubview: label1];
43
+ label1;
44
+ });
69
45
70
46
UILabel *label2 = [[UILabel alloc ] initWithFrame: CGRectMake (0 , 15 , 100 , 15 )];
71
47
label2.right = kScreen_Width - 25 ;
@@ -74,17 +50,17 @@ - (id)initWithFrame:(CGRect)frame {
74
50
label2.textColor = [UIColor colorWithHexString: @" 0x999999" ];
75
51
label2.textAlignment = NSTextAlignmentRight;
76
52
label2.text = @" 查看全部" ;
77
- [subView addSubview: label2];
53
+ [self addSubview: label2];
78
54
79
55
UIImageView *arrow = [[UIImageView alloc ] initWithImage: [UIImage imageNamed: @" task_icon_arrow" ]];
80
56
arrow.centerY = label2.centerY ;
81
57
arrow.right = kScreen_Width - 12 ;
82
- [subView addSubview: arrow];
58
+ [self addSubview: arrow];
83
59
84
60
UIButton *btn = [[UIButton alloc ] initWithFrame: CGRectMake (0 , 0 , kScreen_Width , 42 )];
85
61
btn.backgroundColor = [UIColor clearColor ];
86
62
[btn addTarget: self action: @selector (goAllUsers ) forControlEvents: UIControlEventTouchUpInside];
87
- [subView addSubview: btn];
63
+ [self addSubview: btn];
88
64
89
65
_avatalist = nil ;
90
66
}
@@ -97,33 +73,9 @@ - (void)goAllUsers {
97
73
[self .parentVC.navigationController pushViewController: vc animated: YES ];
98
74
}
99
75
100
- - (void )rightBtnClicked {
101
- if (!self.refTopic ) {
102
- return ;
103
- }
104
-
105
- NSString *path = [NSString stringWithFormat: @" api/tweet_topic/%@ /%@ " , _refTopic[@" id" ], (_watched? @" unwatch" :@" watch" )];
106
-
107
- [[Coding_NetAPIManager sharedManager ]request_Topic_DoWatch_WithUrl:path andBlock: ^(id data, NSError *error) {
108
- if (data) {
109
- self.watched = !self.watched ;
110
- NSString *imageName = self.watched ? @" btn_followed_yes" :@" btn_followed_not" ;
111
- [self .rightBtn setImage: [UIImage imageNamed: imageName] forState: UIControlStateNormal];
112
- }
113
- }];
114
-
115
- }
116
-
117
76
- (void )updateWithTopic : (NSDictionary *)data {
118
- _watched = [data[@" watched" ] boolValue ];
119
77
_refTopic = data;
120
- _nameLabel.text = [NSString stringWithFormat: @" #%@ #" ,data[@" name" ]];
121
-
122
- _userCountLabel.text = [NSString stringWithFormat: @" %@ 人参与/%@ 人关注" ,data[@" speackers" ],data[@" watchers" ]];
123
-
124
- NSString *imageName = self.watched ? @" btn_followed_yes" :@" btn_followed_not" ;
125
- [_rightBtn setImage: [UIImage imageNamed: imageName] forState: UIControlStateNormal];
126
-
78
+ _userCountLabel.text = [NSString stringWithFormat: @" %@ 人参与" ,data[@" speackers" ]];
127
79
}
128
80
129
81
- (void )updateWithJoinedUsers : (NSArray *)userlist {
@@ -132,7 +84,7 @@ - (void)updateWithJoinedUsers:(NSArray*)userlist {
132
84
133
85
for (int i=0 ; i<userlist.count ; i++) {
134
86
User *user = userlist[i];
135
- UIImageView *iconView = [[UIImageView alloc ] initWithFrame: CGRectMake (0 , 114 , 42 , 42 )];
87
+ UIImageView *iconView = [[UIImageView alloc ] initWithFrame: CGRectMake (0 , 57 , 42 , 42 )];
136
88
[iconView doCircleFrame ];
137
89
iconView.left = 16 + i *(9 + 42 );
138
90
if (iconView.right > kScreen_Width ) {
0 commit comments