UILabel+FontAppearance.m 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. //
  2. // UILabel+FontAppearance.m
  3. // RedAnt ERP Mobile
  4. //
  5. // Created by Ray on 11/20/15.
  6. // Copyright © 2015 United Software Applications, Inc. All rights reserved.
  7. //
  8. #import "UILabel+FontAppearance.h"
  9. @implementation UILabel (FontAppearance)
  10. - (void)setAppearanceFont:(UIFont *)font
  11. {
  12. if (self.tag == 1001) {
  13. return;
  14. }
  15. BOOL isBold = (self.font.fontDescriptor.symbolicTraits & UIFontDescriptorTraitBold);
  16. const CGFloat* colors = CGColorGetComponents(self.textColor.CGColor);
  17. if (self.font.pointSize == 14) {
  18. // set font for uialertcontroller title
  19. self.font = [UIFont systemFontOfSize:11];
  20. } else if (self.font.pointSize == 13) {
  21. // set font for uialertcontroller message
  22. self.font = [UIFont systemFontOfSize:11];
  23. } else if (isBold) {
  24. // set font for UIAlertAction with UIAlertActionStyleCancel
  25. self.font = [UIFont systemFontOfSize:12];
  26. } else if ((*colors) == 1) {
  27. // set font for UIAlertAction with UIAlertActionStyleDestructive
  28. self.font = [UIFont systemFontOfSize:13];
  29. } else {
  30. // set font for UIAlertAction with UIAlertActionStyleDefault
  31. self.font = [UIFont systemFontOfSize:14];
  32. }
  33. self.tag = 1001;
  34. }
  35. - (UIFont *)appearanceFont
  36. {
  37. return self.font;
  38. }
  39. @end