NSString+CGSize.m 444 B

123456789101112131415161718192021
  1. //
  2. // NSString+CGSize.m
  3. // TheoryNetwork
  4. //
  5. // Created by tederen on 2019/10/15.
  6. // Copyright © 2019 tederen. All rights reserved.
  7. //
  8. #import "NSString+CGSize.h"
  9. @implementation NSString (CGSize)
  10. + (CGSize)calculateSizeWithString:(NSString *)string fontSize:(CGFloat)size {
  11. UILabel *label = [UILabel new];
  12. label.text = string;
  13. label.font = [UIFont systemFontOfSize:size];
  14. return [label sizeThatFits:CGSizeZero];
  15. }
  16. @end