BTUIKBarButtonItem.m 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #import "BTUIKBarButtonItem.h"
  2. #import "BTUIKAppearance.h"
  3. @implementation BTUIKBarButtonItem
  4. - (instancetype)init {
  5. if (self = [super init]) {
  6. [self updateTitleTextAttributes];
  7. }
  8. return self;
  9. }
  10. - (void)setBold:(BOOL)bold {
  11. _bold = bold;
  12. [self updateTitleTextAttributes];
  13. }
  14. - (void)updateTitleTextAttributes {
  15. UIFont *font;
  16. if (self.bold) {
  17. font = [[BTUIKAppearance sharedInstance].boldFont fontWithSize:UIFont.labelFontSize];
  18. } else {
  19. font = [[BTUIKAppearance sharedInstance].font fontWithSize:UIFont.labelFontSize];
  20. }
  21. [self setTitleTextAttributes:@{NSForegroundColorAttributeName: [BTUIKAppearance sharedInstance].tintColor,
  22. NSFontAttributeName:font}
  23. forState:UIControlStateNormal];
  24. [self setTitleTextAttributes:@{NSForegroundColorAttributeName: [BTUIKAppearance sharedInstance].tintColor,
  25. NSFontAttributeName:font}
  26. forState:UIControlStateNormal | UIControlStateHighlighted];
  27. [self setTitleTextAttributes:@{NSForegroundColorAttributeName: [BTUIKAppearance sharedInstance].disabledColor,
  28. NSFontAttributeName:font}
  29. forState:UIControlStateDisabled];
  30. }
  31. @end