PaddingLabel.m 793 B

12345678910111213141516171819202122232425262728293031323334353637
  1. //
  2. // PaddingLabel.m
  3. // LenzCameraNativeModuleForRN
  4. //
  5. // Created by 王昭威 on 2023/1/31.
  6. //
  7. #import "PaddingLabel.h"
  8. @implementation PaddingLabel
  9. - (void)setPadding:(UIEdgeInsets)padding{
  10. _padding = padding;
  11. [self invalidateIntrinsicContentSize];
  12. }
  13. - (void)awakeFromNib{
  14. [super awakeFromNib];
  15. _padding = UIEdgeInsetsMake(10, 2.5, 10, 2.5);
  16. self.textAlignment = NSTextAlignmentCenter;
  17. }
  18. - (void)drawTextInRect:(CGRect)rect{
  19. [super drawTextInRect:CGRectInset(rect, self.padding.left + self.padding.right, self.padding.top + self.padding.bottom)];
  20. }
  21. /*
  22. // Only override drawRect: if you perform custom drawing.
  23. // An empty implementation adversely affects performance during animation.
  24. - (void)drawRect:(CGRect)rect {
  25. // Drawing code
  26. }
  27. */
  28. @end