MTBaseLabel.m 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. //
  2. // MTBaseLabel.m
  3. //
  4. // Created by Simon on 2019/3/22.
  5. // Copyright © 2019 Simon. All rights reserved.
  6. //
  7. #import "MTBaseLabel.h"
  8. @implementation MTBaseLabel
  9. //UILable方法实现
  10. +(MTBaseLabel *)labelWithFrame:(CGRect)rect backGroundColor:(UIColor *)color1 text:(NSString *)text textColor:(UIColor *)color2 font:(UIFont *)floatFont
  11. {
  12. MTBaseLabel *lb = [[MTBaseLabel alloc]init];
  13. lb.frame = rect;
  14. lb.backgroundColor = color1;
  15. lb.text = text;
  16. lb.textColor = color2;
  17. lb.font = floatFont;
  18. return lb;
  19. }
  20. +(MTBaseLabel *)labelWithTextColor:(UIColor *)color font:(UIFont *)floatFont{
  21. MTBaseLabel *lb = [[MTBaseLabel alloc]init];
  22. lb.textColor = color;
  23. lb.font = floatFont;
  24. return lb;
  25. }
  26. +(MTBaseLabel *)labelWithText:(NSString *)text andColor:(UIColor *)color font:(UIFont *)floatFont{
  27. MTBaseLabel *lb = [[MTBaseLabel alloc]init];
  28. lb.textColor = color;
  29. lb.font = floatFont;
  30. lb.text = text;
  31. return lb;
  32. }
  33. - (instancetype)init
  34. {
  35. self = [super init];
  36. if (self) {
  37. self.adjustsFontSizeToFitWidth = YES;
  38. }
  39. return self;
  40. }
  41. /*
  42. // Only override drawRect: if you perform custom drawing.
  43. // An empty implementation adversely affects performance during animation.
  44. - (void)drawRect:(CGRect)rect {
  45. // Drawing code
  46. }
  47. */
  48. @end