MJIMGUpTextDownBtn.m 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. //
  2. // MJIMGUpTextDownBtn.m
  3. // weizhuMerchant
  4. //
  5. // Created by mac on 2019/7/17.
  6. // Copyright © 2019 mac. All rights reserved.
  7. //
  8. #import "MJIMGUpTextDownBtn.h"
  9. #import "UIView+LK.h"
  10. @implementation MJIMGUpTextDownBtn
  11. - (void)setup
  12. {
  13. self.titleLabel.textAlignment = NSTextAlignmentCenter;
  14. self.titleLabel.font = [UIFont systemFontOfSize:15];
  15. //[self setTitle:@"blackColor" forState:UIControlStateNormal];
  16. [self setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  17. // self.imageView.backgroundColor=[UIColor orangeColor];
  18. // self.backgroundColor=[UIColor greenColor];
  19. // self.imageView.layer.cornerRadius=5;
  20. // self.imageView.layer.masksToBounds=YES;
  21. // [self setBackgroundImage:[UIImage imageNamed:@"mainCellBackground"] forState:UIControlStateNormal];
  22. }
  23. - (instancetype)initWithFrame:(CGRect)frame
  24. {
  25. if (self = [super initWithFrame:frame]) {
  26. self.contentMode=UIViewContentModeScaleAspectFit;
  27. [self setup];
  28. }
  29. return self;
  30. }
  31. - (void)awakeFromNib
  32. {
  33. [super awakeFromNib];
  34. [self setup];
  35. }
  36. - (void)layoutSubviews
  37. {
  38. [super layoutSubviews];
  39. self.imageView.xmg_y = 0;
  40. self.imageView.xmg_width = self.xmg_width*0.3 ;
  41. self.imageView.xmg_height = self.xmg_width*0.3;
  42. self.imageView.xmg_centerX = self.xmg_width * 0.5;
  43. // self.imageView.xmg_centerY = self.xmg_width * 0.5;
  44. self.titleLabel.xmg_x = 0;
  45. self.titleLabel.xmg_y = CGRectGetMaxY(self.imageView.frame)+5;
  46. self.titleLabel.xmg_width = self.xmg_width;
  47. self.titleLabel.xmg_height = self.xmg_height - self.titleLabel.xmg_y;
  48. }
  49. @end