YOUPAIMessafeTemplateListCell.m 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. //
  2. // YOUPAIMessafeTemplateListCell.m
  3. // MSYOUPAI
  4. //
  5. // Created by admin on 2022/3/11.
  6. // Copyright © 2022 MS. All rights reserved.
  7. //
  8. #import "YOUPAIMessafeTemplateListCell.h"
  9. @implementation YOUPAIMessafeTemplateListCell
  10. -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  11. if(self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]){
  12. [self youpaifMakeUI];
  13. [self youpaifMakeLayout];
  14. }
  15. return self;
  16. }
  17. // 标题
  18. -(UILabel *)youpaiptitleLab{
  19. if(_youpaiptitleLab == nil){
  20. _youpaiptitleLab = [UILabel new];
  21. _youpaiptitleLab.font = LCFont14;
  22. _youpaiptitleLab.textColor = LZ273145Color;
  23. }
  24. return _youpaiptitleLab;
  25. }
  26. // 编辑
  27. -(UIButton *)youpaipeditBtn{
  28. if(_youpaipeditBtn == nil){
  29. _youpaipeditBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 32, 32)];
  30. [_youpaipeditBtn setImage:[UIImage imageNamed:@"icon_messagetemplate_edit"] forState:UIControlStateNormal];
  31. }
  32. return _youpaipeditBtn;
  33. }
  34. // 删除
  35. -(UIButton *)youpaipdeleteBtn{
  36. if(_youpaipdeleteBtn == nil){
  37. _youpaipdeleteBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 32, 32)];
  38. [_youpaipdeleteBtn setImage:[UIImage imageNamed:@"icon_messagetemplate_delete"] forState:UIControlStateNormal];
  39. }
  40. return _youpaipdeleteBtn;
  41. }
  42. // 选中
  43. -(UIButton *)youpaipselectBtn{
  44. if(_youpaipselectBtn == nil){
  45. _youpaipselectBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 78, 32)];
  46. [_youpaipselectBtn setImage:[UIImage imageNamed:@"icon_messagetemplate_unselect"] forState:UIControlStateNormal];
  47. [_youpaipselectBtn setImage:[UIImage imageNamed:@"icon_messagetemplate_select"] forState:UIControlStateSelected];
  48. _youpaipselectBtn.titleLabel.font = LCFont12;
  49. [_youpaipselectBtn setTitleColor:LZ273145Color forState:UIControlStateNormal];
  50. [_youpaipselectBtn setTitle:@"使用此模板" forState:UIControlStateNormal];
  51. }
  52. return _youpaipselectBtn;
  53. }
  54. // 分割线
  55. -(UIView *)youpaiplineView{
  56. if(_youpaiplineView == nil){
  57. _youpaiplineView = [UIView new];
  58. _youpaiplineView.backgroundColor = LZF5F4F7Color;
  59. }
  60. return _youpaiplineView;
  61. }
  62. // 文字信息
  63. -(UILabel *)youpaiptextLab{
  64. if(_youpaiptextLab == nil){
  65. _youpaiptextLab = [UILabel new];
  66. _youpaiptextLab.textColor = LZ273145Color;
  67. _youpaiptextLab.font = LCFont12;
  68. }
  69. return _youpaiptextLab;
  70. }
  71. // 图片信息
  72. -(UIImageView *)youpaipimgView{
  73. if(_youpaipimgView == nil){
  74. _youpaipimgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 60, 60)];
  75. [_youpaipimgView ms_radius:10];
  76. }
  77. return _youpaipimgView;
  78. }
  79. // 视频信息
  80. -(UIImageView *)youpaipvideoView{
  81. if(_youpaipvideoView == nil){
  82. _youpaipvideoView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 60, 60)];
  83. [_youpaipvideoView ms_radius:10];
  84. _youpaipvideoView.contentMode = UIViewContentModeScaleAspectFill;
  85. }
  86. return _youpaipvideoView;
  87. }
  88. -(UIImageView *)youpaipvideoPlayerView{
  89. if(_youpaipvideoPlayerView == nil){
  90. _youpaipvideoPlayerView = [UIImageView new];
  91. [_youpaipvideoPlayerView ms_radius:10];
  92. UIImage *img = [UIImage imageNamed:@"icon_messagetemplate_player_samll"];
  93. _youpaipvideoPlayerView.image = img;
  94. [_youpaipvideoPlayerView ms_radius:img.size.width/2];
  95. _youpaipvideoPlayerView.contentMode = UIViewContentModeCenter;
  96. }
  97. return _youpaipvideoPlayerView;
  98. }
  99. -(UILabel *)youpaipvoideCutDownLab{
  100. if(_youpaipvoideCutDownLab == nil){
  101. _youpaipvoideCutDownLab = [UILabel new];
  102. _youpaipvoideCutDownLab.font = LCFont12;
  103. _youpaipvoideCutDownLab.textColor = UIColor.whiteColor;
  104. }
  105. return _youpaipvoideCutDownLab;
  106. }
  107. -(UIImageView *)youpaipvoiceView{
  108. if(_youpaipvoiceView == nil){
  109. _youpaipvoiceView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 78, 25)];
  110. _youpaipvoiceView.image = [UIImage imageNamed:@"icon_messagetemplate_voice"];
  111. }
  112. return _youpaipvoiceView;
  113. }
  114. -(UIStackView *)headerStackView{
  115. if(_headerStackView == nil){
  116. _headerStackView = [UIStackView new];
  117. _headerStackView.spacing = 12;
  118. }
  119. return _headerStackView;
  120. }
  121. -(UIStackView *)contentStackView{
  122. if(_contentStackView == nil){
  123. _contentStackView = [UIStackView new];
  124. _contentStackView.alignment = UIStackViewAlignmentBottom;
  125. _contentStackView.spacing = 12;
  126. }
  127. return _contentStackView;
  128. }
  129. -(UIImageView *)youpaipstateImageView{
  130. if(_youpaipstateImageView == nil){
  131. _youpaipstateImageView = [UIImageView new];
  132. _youpaipstateImageView.image = [UIImage imageNamed:@"icon_messagetemplate_reviewfailure"];
  133. }
  134. return _youpaipstateImageView;
  135. }
  136. -(void)youpaifMakeUI{
  137. [self setSelectionStyle:UITableViewCellSelectionStyleNone];
  138. [self.contentView ms_radius:10];
  139. self.contentView.backgroundColor = UIColor.whiteColor;
  140. [self.contentView addSubview:self.youpaiptitleLab];
  141. [self.contentView addSubview:self.headerStackView];
  142. [self.headerStackView addArrangedSubview:self.youpaipeditBtn];
  143. [self.headerStackView addArrangedSubview:self.youpaipdeleteBtn];
  144. [self.headerStackView addArrangedSubview:self.youpaipselectBtn];
  145. [self.contentView addSubview:self.youpaiplineView];
  146. [self.contentView addSubview:self.youpaiptitleLab];
  147. [self.contentView addSubview:self.youpaipstateImageView];
  148. [self.contentView addSubview:self.youpaiptextLab];
  149. [self.contentView addSubview:self.contentStackView];
  150. [self.contentStackView addArrangedSubview:self.youpaipimgView];
  151. [self.contentStackView addArrangedSubview:self.youpaipvideoView];
  152. [self.contentStackView addArrangedSubview:self.youpaipvoiceView];
  153. [self.youpaipvideoView addSubview:self.youpaipvideoPlayerView];
  154. [self.youpaipvoiceView addSubview:self.youpaipvoideCutDownLab];
  155. }
  156. -(void)youpaifMakeLayout{
  157. [_youpaiptitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
  158. make.left.mas_equalTo(12);
  159. make.top.mas_equalTo(20);
  160. }];
  161. [_headerStackView mas_makeConstraints:^(MASConstraintMaker *make) {
  162. make.right.mas_equalTo(-12);
  163. make.centerY.mas_equalTo(self.youpaiptitleLab.mas_centerY);
  164. make.height.mas_equalTo(14);
  165. }];
  166. [_youpaiplineView mas_makeConstraints:^(MASConstraintMaker *make) {
  167. make.top.mas_equalTo(54);
  168. make.height.mas_equalTo(0.5);
  169. make.left.mas_equalTo(15);
  170. make.right.mas_equalTo(-15);
  171. }];
  172. [_youpaiptextLab mas_makeConstraints:^(MASConstraintMaker *make) {
  173. make.left.mas_equalTo(12);
  174. make.top.mas_equalTo(self.youpaiplineView).offset(20);
  175. }];
  176. [_contentStackView mas_makeConstraints:^(MASConstraintMaker *make) {
  177. make.left.mas_equalTo(12);
  178. make.height.mas_equalTo(60);
  179. make.bottom.mas_equalTo(-20);
  180. }];
  181. [_youpaipimgView mas_makeConstraints:^(MASConstraintMaker *make) {
  182. make.size.mas_equalTo(60);
  183. }];
  184. [_youpaipvideoView mas_makeConstraints:^(MASConstraintMaker *make) {
  185. make.size.mas_equalTo(60);
  186. }];
  187. [_youpaipstateImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  188. make.right.mas_equalTo(-12);
  189. make.bottom.mas_equalTo(-16);
  190. }];
  191. [_youpaipvoideCutDownLab mas_makeConstraints:^(MASConstraintMaker *make) {
  192. make.centerY.mas_equalTo(0);
  193. make.right.mas_equalTo(0).offset(-6);
  194. }];
  195. [_youpaipvideoPlayerView mas_makeConstraints:^(MASConstraintMaker *make) {
  196. make.center.mas_equalTo(0);
  197. }];
  198. [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
  199. make.left.mas_equalTo(12);
  200. make.right.mas_equalTo(-12);
  201. make.top.mas_equalTo(8);
  202. make.bottom.mas_equalTo(-1);
  203. }];
  204. }
  205. @end