Açıklama Yok

KXLoanButton.m 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. //
  2. // KXLoanButton.m
  3. // QBCS
  4. //
  5. // Created by kuxuan on 2017/6/5.
  6. // Copyright © 2017年 kuxuan. All rights reserved.
  7. //
  8. #import "KXLoanButton.h"
  9. @implementation KXLoanButton
  10. {
  11. UIImageView *_picView;
  12. UILabel *_titleLabel;
  13. UILabel *_descLabel;
  14. }
  15. -(instancetype)initWithFrame:(CGRect)frame
  16. {
  17. if (self==[super initWithFrame:frame]) {
  18. self.backgroundColor=[UIColor whiteColor];
  19. [self setupUI];
  20. }
  21. return self;
  22. }
  23. -(void)setupUI
  24. {
  25. _picView=[[UIImageView alloc]init];
  26. [self addSubview:_picView];
  27. _titleLabel=[[UILabel alloc]init];
  28. _titleLabel.font=[UIFont systemFontOfSize:14*SCREEN_MUTI];
  29. _titleLabel.textColor=[UIColor KXColorWithHex:0x333333];
  30. _titleLabel.textAlignment = NSTextAlignmentLeft;
  31. [self addSubview:_titleLabel];
  32. _descLabel = [[UILabel alloc] init];
  33. _descLabel.font = FONT_SYS(12);
  34. _descLabel.textColor = [UIColor detailTitleColor];
  35. _descLabel.textAlignment = NSTextAlignmentLeft;
  36. [self addSubview:_descLabel];
  37. self.redButton = [UIButton buttonWithType:UIButtonTypeCustom];
  38. [self.redButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  39. self.redButton.titleLabel.font = FONT_SYS(6*SCREEN_MUTI);
  40. self.redButton.titleEdgeInsets = UIEdgeInsetsMake(-4*SCREEN_MUTI, 0, 0, 0);
  41. [self.redButton setBackgroundImage:[UIImage imageNamed:@"main_new"] forState:UIControlStateNormal];
  42. [self addSubview:self.redButton];
  43. [_picView mas_makeConstraints:^(MASConstraintMaker *make) {
  44. make.left.equalTo(self.mas_left).offset(Fitsize(9));
  45. make.size.equalTo(CGSizeMake(Fitsize(41), Fitsize(41)));
  46. make.centerY.equalTo(self.mas_centerY);
  47. }];
  48. [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  49. make.left.equalTo(_picView.mas_right).offset(Fitsize(10));
  50. make.top.equalTo(_picView.mas_top);
  51. }];
  52. [_descLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  53. make.left.equalTo(_titleLabel.mas_left);
  54. make.bottom.equalTo(_picView.mas_bottom);
  55. }];
  56. [self.redButton mas_makeConstraints:^(MASConstraintMaker *make) {
  57. make.top.equalTo(_titleLabel.mas_top);
  58. make.left.equalTo(_titleLabel.mas_right).offset(Fitsize(6));
  59. make.size.equalTo(CGSizeMake(Fitsize(14), Fitsize(11)));
  60. }];
  61. }
  62. -(void)setName:(NSString *)name
  63. {
  64. _name=name;
  65. _titleLabel.text=name;
  66. }
  67. -(void)setButtonImage:(UIImage *)buttonImage
  68. {
  69. _buttonImage=buttonImage;
  70. _picView.image=buttonImage;
  71. }
  72. - (void)setDescName:(NSString *)descName{
  73. _descName = descName;
  74. _descLabel.text = descName;
  75. }
  76. @end