MyButton.m 967 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. //
  2. // MyButton.m
  3. // 振飞商城
  4. //
  5. // Created by 123 on 2020/5/25.
  6. // Copyright © 2020 Vibration Fly. All rights reserved.
  7. //
  8. #import "MyButton.h"
  9. #import "UIView+LK.h"
  10. @implementation MyButton
  11. -(instancetype)initWithFrame:(CGRect)frame{
  12. if (self=[super initWithFrame:frame]) {
  13. // [self setTitleColor:kRGBColor51 forState:UIControlStateNormal];
  14. self.titleLabel.font= [UIFont systemFontOfSize:12 weight:UIFontWeightMedium];
  15. }
  16. return self;
  17. }
  18. - (void)layoutSubviews{
  19. [super layoutSubviews];
  20. self.imageView.xmg_y=10;
  21. self.imageView.xmg_x=(self.xmg_width-self.imageView.xmg_width)/2;
  22. self.titleLabel.xmg_y=CGRectGetMaxY(self.imageView.frame)+5;
  23. self.titleLabel.xmg_width=self.xmg_width;
  24. self.titleLabel.xmg_x=0;
  25. //self.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
  26. self.titleLabel.textAlignment=NSTextAlignmentCenter;
  27. }
  28. @end