1313
1414@interface CSTopicHeaderView ()
1515@property (nonatomic ,strong )NSDictionary *refTopic;
16- @property (nonatomic ,strong )UIButton *rightBtn;
16+ // @property (nonatomic,strong)UIButton *rightBtn;
1717@property (nonatomic ,strong )NSMutableArray *avatalist;
1818@property (nonatomic ,assign )BOOL watched;
1919@end
2020
2121@implementation CSTopicHeaderView {
22- UILabel *_nameLabel;
22+ // UILabel *_nameLabel;
2323 UILabel *_userCountLabel;
2424}
2525
2626- (id )initWithFrame : (CGRect)frame {
2727 self = [super initWithFrame: frame];
2828 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 ;
5731
5832 UIView *sepLine = [[UIView alloc ] initWithFrame: CGRectMake (12 , 41 , kScreen_Width - 12 , 0.5 )];
5933 sepLine.backgroundColor = [UIColor colorWithHexString: @" 0xdddddd" ];
60- [subView addSubview: sepLine];
34+ [self addSubview: sepLine];
6135
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+ });
6945
7046 UILabel *label2 = [[UILabel alloc ] initWithFrame: CGRectMake (0 , 15 , 100 , 15 )];
7147 label2.right = kScreen_Width - 25 ;
@@ -74,17 +50,17 @@ - (id)initWithFrame:(CGRect)frame {
7450 label2.textColor = [UIColor colorWithHexString: @" 0x999999" ];
7551 label2.textAlignment = NSTextAlignmentRight;
7652 label2.text = @" 查看全部" ;
77- [subView addSubview: label2];
53+ [self addSubview: label2];
7854
7955 UIImageView *arrow = [[UIImageView alloc ] initWithImage: [UIImage imageNamed: @" task_icon_arrow" ]];
8056 arrow.centerY = label2.centerY ;
8157 arrow.right = kScreen_Width - 12 ;
82- [subView addSubview: arrow];
58+ [self addSubview: arrow];
8359
8460 UIButton *btn = [[UIButton alloc ] initWithFrame: CGRectMake (0 , 0 , kScreen_Width , 42 )];
8561 btn.backgroundColor = [UIColor clearColor ];
8662 [btn addTarget: self action: @selector (goAllUsers ) forControlEvents: UIControlEventTouchUpInside];
87- [subView addSubview: btn];
63+ [self addSubview: btn];
8864
8965 _avatalist = nil ;
9066 }
@@ -97,33 +73,9 @@ - (void)goAllUsers {
9773 [self .parentVC.navigationController pushViewController: vc animated: YES ];
9874}
9975
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-
11776- (void )updateWithTopic : (NSDictionary *)data {
118- _watched = [data[@" watched" ] boolValue ];
11977 _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" ]];
12779}
12880
12981- (void )updateWithJoinedUsers : (NSArray *)userlist {
@@ -132,7 +84,7 @@ - (void)updateWithJoinedUsers:(NSArray*)userlist {
13284
13385 for (int i=0 ; i<userlist.count ; i++) {
13486 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 )];
13688 [iconView doCircleFrame ];
13789 iconView.left = 16 + i *(9 + 42 );
13890 if (iconView.right > kScreen_Width ) {
0 commit comments