CNLiveFontSettingCell.m
2.67 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
//
// CNLiveFontSettingCell.m
// CNLiveSettingModule
//
// Created by 153993236@qq.com on 11/12/2019.
// Copyright (c) 2019 153993236@qq.com. All rights reserved.
//
#import "CNLiveFontSettingCell.h"
#import <SDWebImage/SDWebImage.h>
#import "CNLiveBaseKit.h"
#import "CNLiveCategory.h"
#import "CNLiveFontSettingModel.h"
#import "CNLiveFontSettingFrame.h"
#import "CNLiveFontSettingContentButton.h"
@interface CNLiveFontSettingCell()
@property (nonatomic, strong) UIImageView *headImage;//头像
@property (nonatomic, strong) CNLiveFontSettingContentButton *btnContent;//显示内容
@end
@implementation CNLiveFontSettingCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
self.backgroundColor = [UIColor clearColor];
self.selectionStyle = UITableViewCellSelectionStyleNone;
self.headImage = [[UIImageView alloc]init];
_headImage.backgroundColor = [UIColor clearColor];
_headImage.layer.masksToBounds = YES;
_headImage.layer.cornerRadius = 3;
[self.contentView addSubview:self.headImage];
self.btnContent = [[CNLiveFontSettingContentButton alloc]init];
[self.contentView addSubview:self.btnContent];
}
return self;
}
#pragma mark - 内容及Frame设置
- (void)setFontSettingFrame:(CNLiveFontSettingFrame *)fontSettingFrame{
_fontSettingFrame = fontSettingFrame;
CNLiveFontSettingModel *model = fontSettingFrame.model;
// 1.设置头像
self.headImage.frame = fontSettingFrame.iconFrame;
UIImage *image = [UIImage cn_getImageName:@"font_size_logo" bundleName:@"CNLiveSettingModule" targetClass:[self class]];
[_headImage sd_setImageWithURL:[NSURL URLWithString:model.icon] placeholderImage:image];
// 2.设置内容
self.btnContent.fontSettingFrame = fontSettingFrame;//这里设置内容的frame等
}
/**
* 创建图片
*
* @param imageName 图片名字
* @param bundleName 图片所在的bundle名字
* @param targetClass 类和bundle的同级目录
* @return 返回UIImage
*/
- (UIImage *)xw_getImageName:(NSString *)imageName bundleName:(NSString *)bundleName targetClass:(Class)targetClass{
NSBundle *bundle = [NSBundle bundleForClass:targetClass];
NSURL *url = [bundle URLForResource:bundleName withExtension:@"bundle"];
NSBundle *targetBundle = [NSBundle bundleWithURL:url];
UIImage *image = [UIImage imageNamed:imageName inBundle:targetBundle compatibleWithTraitCollection:nil];
return image?image:[UIImage imageNamed:imageName inBundle:[NSBundle mainBundle] compatibleWithTraitCollection:nil];
}
@end