CourseMusicCell.m
2.4 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
//
// CourseMusicCell.m
// DreamSleep
//
// Created by peter on 2022/5/11.
//
#import "CourseMusicCell.h"
#import "LookAllController.h"
#import "SafeHelperCollectionView.h"
@interface CourseMusicCell ()
@property (nonatomic, strong) UIButton *moreBtn;
@property (nonatomic, strong) SafeHelperCollectionView *shCollectionView;
@end
@implementation CourseMusicCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
[self.contentView addSubview:self.moreBtn];
[self.contentView addSubview:self.shCollectionView];
[self.moreBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.contentView.mas_right).offset(-5);
make.width.equalTo(@100);
make.height.equalTo(@30);
make.centerY.equalTo(self.verticalView.mas_centerY);
}];
[self.shCollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.titleLab.mas_bottom).offset(17);
make.left.equalTo(self.verticalView);
make.right.equalTo(self.contentView);
make.bottom.equalTo(self.contentView);
}];
}
return self;
}
- (void)updateCourseMusicListWithData:(NSArray *)dataArr cellIndex:(NSInteger)cellIndex {
[self.shCollectionView reloadWithData:dataArr cellIndex:cellIndex];
}
- (void)lookAllAction {
NSInteger defaultIndex = self.model.type == CellTypeCourse ? 0 : 1;
LookAllController *lookAllVC = [[LookAllController alloc] initWithDefaultIndex:defaultIndex];
[self.ds_viewController.navigationController pushViewController:lookAllVC animated:YES];
}
#pragma mark - lazy
- (UIButton *)moreBtn {
if (!_moreBtn) {
_moreBtn = [UIButton dkBtnWithSubTitle:@"查看全部" imgName:@"rightRow" font:SysFont(12)];
_moreBtn.frame = CGRectMake(0, 0, 100, 40);
[_moreBtn adjustLayoutWithType:UIButtonLayoutTypeLeftTitleRightImage midSpace:4 sizeToFit:NO];
[_moreBtn addTarget:self action:@selector(lookAllAction) forControlEvents:UIControlEventTouchUpInside];
}
return _moreBtn;
}
- (SafeHelperCollectionView *)shCollectionView {
if (!_shCollectionView) {
_shCollectionView = [[SafeHelperCollectionView alloc] initWithCellIndex:self.cellIndex];
}
return _shCollectionView;
}
@end