FUMakeButton.m 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. //
  2. // FUMakeButton.m
  3. // FULiveDemo
  4. //
  5. // Created by 孙慕 on 2019/6/20.
  6. // Copyright © 2019 FaceUnity. All rights reserved.
  7. //
  8. #import "FUMakeButton.h"
  9. @implementation FUMakeButton
  10. - (instancetype)initWithFrame:(CGRect)frame
  11. {
  12. if (self = [super initWithFrame:frame]) {
  13. self.titleLabel.textAlignment = NSTextAlignmentCenter;
  14. // 设置按钮颜色
  15. // self.selected = NO;
  16. // [self setTitleColor:[FUDresserstyle colorForTitle] forState:UIControlStateNormal];
  17. // // self.selected = YES;
  18. // [self setTitleColor:[FUDresserstyle colorForTitle_sel] forState:UIControlStateSelected];
  19. // [self setTitleColor:[FUDresserstyle colorForTitle_sel] forState:UIControlStateHighlighted];
  20. self.titleLabel.font = [UIFont systemFontOfSize:10];
  21. }
  22. return self;
  23. }
  24. -(instancetype)initWithCoder:(NSCoder *)aDecoder{
  25. if (self = [super initWithCoder:aDecoder]) {
  26. self.titleLabel.textAlignment = NSTextAlignmentCenter;
  27. // 设置按钮颜色
  28. // self.selected = NO;
  29. [self setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  30. // // self.selected = YES;
  31. // [self setTitleColor:[FUDresserstyle colorForTitle_sel] forState:UIControlStateSelected];
  32. // [self setTitleColor:FUColor_HEX(0x808182) forState:UIControlStateHighlighted];
  33. self.titleLabel.font = [UIFont systemFontOfSize:10];
  34. }
  35. return self;
  36. }
  37. - (void)layoutSubviews
  38. {
  39. [super layoutSubviews];
  40. CGRect frame = self.imageView.bounds;
  41. CGRect frame1 = self.titleLabel.frame;
  42. self.imageView.frame = frame;
  43. CGPoint center = self.imageView.center;
  44. center.x = self.frame.size.width * 0.5;
  45. // center.y = self.center.y - frame.size.height/2 - 5;
  46. self.imageView.center = center;
  47. frame1.origin.x = 0;
  48. frame1.origin.y = CGRectGetMaxY(self.imageView.frame) + 5;
  49. frame1.size.height = 11;
  50. frame1.size.width = self.bounds.size.width;;
  51. self.titleLabel.frame = frame1;
  52. }
  53. @end