单军华
2018-04-18 de88ae127e305e0b153c327b073645f9353cace5
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
//
//  MusicPlayCell.m
//  istanbul
//
//  Created by WindShan on 2017/6/16.
//  Copyright © 2017年 WindShan. All rights reserved.
//
 
#import "MusicPlayCell.h"
#import "GloriaLabel.h"
 
@interface MusicPlayCell()
{
    
}
 
@property (nonatomic, strong)     GloriaLabel * NumberLabel;
@property (nonatomic, strong)     GloriaLabel * musicNameLabel;
@property (nonatomic, strong)     GloriaLabel * LevelsNameLabel;
@property (nonatomic, strong)     UIButton    * personalLikeBtn;
@property (nonatomic, strong)     UIButton    * userPlayBtn;
@end
 
@implementation MusicPlayCell
 
/*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.
 - (void)drawRect:(CGRect)rect {
 // Drawing code
 }
 */
 
- (void)layoutSubviews
{
    [super layoutSubviews];
    
    self.NumberLabel.frame = CGRectMake(20, 10, 40, 30);
    
    self.musicNameLabel.frame = CGRectMake(20+40, 25, SCREEN_WIDTH/2, 20);
    self.LevelsNameLabel.frame = CGRectMake(20+40, 5, SCREEN_WIDTH/2, 20);
    
    self.personalLikeBtn.frame = CGRectMake(SCREEN_WIDTH-20-15, 17, 15, 15);
    self.userPlayBtn.frame     = CGRectMake(SCREEN_WIDTH-20-15-50-15, 17, 15, 15);
}
 
-(UIButton*)userPlayBtn
{
    if(!_userPlayBtn)
    {
        _userPlayBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _userPlayBtn.frame = CGRectMake(0, SCREEN_HEIGHT-100, 118, 30);
        [_userPlayBtn setBackgroundImage:[UIImage imageNamed:@"icon_start" ] forState:UIControlStateNormal];
        [_userPlayBtn addTarget:self action:@selector(playAction) forControlEvents:UIControlEventTouchUpInside];
        [self.contentView addSubview:_userPlayBtn];
    }
    
    return _userPlayBtn;
}
 
-(void)playAction
{
    if ( _delegate && [_delegate respondsToSelector:@selector(musicPlaySection:)])
    {
        self.model.playStatus = (self.model.playStatus == 1 ? 2:1);
        self.model.cmd = 1;
        [_delegate musicPlaySection:self.model];
    }
}
 
-(UIButton*)personalLikeBtn
{
    if(!_personalLikeBtn)
    {
        _personalLikeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _personalLikeBtn.frame = CGRectMake(0, SCREEN_HEIGHT-100, 118, 30);
        [_personalLikeBtn setBackgroundImage:[UIImage imageNamed:@"icon_unlike" ] forState:UIControlStateNormal];
        [_personalLikeBtn addTarget:self action:@selector(personalLikeAction) forControlEvents:UIControlEventTouchUpInside];
        [self.contentView addSubview:_personalLikeBtn];
    }
    
    return _personalLikeBtn;
}
 
-(void)personalLikeAction
{
    if ( _delegate && [_delegate respondsToSelector:@selector(musicPlaySection:)])
    {
        self.model.setStatus = (self.model.setStatus == 1 ? 2:1);
        self.model.cmd = 2;
        [_delegate musicPlaySection:self.model];
    }
}
 
- (GloriaLabel *) LevelsNameLabel
{
    if(!_LevelsNameLabel)
    {
        _LevelsNameLabel = [[GloriaLabel alloc] initWithFrame:CGRectMake(10+50+10+80, 28,150, 14)];
        _LevelsNameLabel.font = [UIFont systemFontOfSize:16];
        _LevelsNameLabel.textAlignment = UITextAlignmentLeft;
        _LevelsNameLabel.textColor = kUIColorFromRGB(0x595959);
        [self.contentView addSubview:_LevelsNameLabel];
    }
    
    return _LevelsNameLabel;
}
 
- (GloriaLabel *) NumberLabel
{
    if(!_NumberLabel)
    {
        _NumberLabel = [[GloriaLabel alloc] initWithFrame:CGRectMake(10+50+10+80, 28,150, 14)];
        _NumberLabel.font = [UIFont systemFontOfSize:16];
        _NumberLabel.textAlignment = UITextAlignmentLeft;
        _NumberLabel.textColor = kUIColorFromRGB(0xc4c4c4);
        [self.contentView addSubview:_NumberLabel];
    }
    
    return _NumberLabel;
}
 
- (GloriaLabel *) musicNameLabel
{
    if(!_musicNameLabel)
    {
        _musicNameLabel = [[GloriaLabel alloc] initWithFrame:CGRectMake(10+50+10+80, 28,150, 14)];
        _musicNameLabel.font = [UIFont systemFontOfSize:16];
        _musicNameLabel.textAlignment = UITextAlignmentLeft;
        _musicNameLabel.textColor = kUIColorFromRGB(0xc4c4c4);
        [self.contentView addSubview:_musicNameLabel];
    }
    
    return _musicNameLabel;
}
 
- (void)setItemView:(MusicModel*)model
{
    self.model = model;
    //icon_musicset
    [self.userPlayBtn setBackgroundImage:[UIImage imageNamed: model.playStatus == 1 ?@"icon_play":@"icon_start" ] forState:UIControlStateNormal];
    [self.personalLikeBtn setBackgroundImage:[UIImage imageNamed: @"icon_voiceset"] forState:UIControlStateNormal];
    [self.NumberLabel setText:model.xuhaoIndex];
    [self.musicNameLabel setText:model.musicName];
    [self.LevelsNameLabel setText:model.username];
    
}
 
- (void)setItemView:(MusicModel *) model setName:(NSString*)name
{
    self.model = model;
    //icon_musicset
    [self.userPlayBtn setBackgroundImage:[UIImage imageNamed: model.playStatus == 1 ?@"icon_play":@"icon_start" ] forState:UIControlStateNormal];
    [self.personalLikeBtn setBackgroundImage:[UIImage imageNamed: name] forState:UIControlStateNormal];
    [self.NumberLabel setText:model.xuhaoIndex];
    [self.musicNameLabel setText:model.musicName];
    [self.LevelsNameLabel setText:model.username];
}
@end