react-native-navigation的迁移库

RNNFontAttributesCreator.m 823B

1234567891011121314151617181920212223242526
  1. #import "RNNFontAttributesCreator.h"
  2. @implementation RNNFontAttributesCreator
  3. + (NSDictionary *)createFontAttributesWithFontFamily:(NSString *)fontFamily fontSize:(NSNumber *)fontSize color:(UIColor *)color {
  4. NSMutableDictionary* titleTextAttributes = [NSMutableDictionary new];
  5. if (fontFamily || fontSize || color) {
  6. if (color) {
  7. titleTextAttributes[NSForegroundColorAttributeName] = color;
  8. }
  9. if (fontFamily){
  10. if (fontSize) {
  11. titleTextAttributes[NSFontAttributeName] = [UIFont fontWithName:fontFamily size:[fontSize floatValue]];
  12. } else {
  13. titleTextAttributes[NSFontAttributeName] = [UIFont fontWithName:fontFamily size:17];
  14. }
  15. } else if (fontSize) {
  16. titleTextAttributes[NSFontAttributeName] = [UIFont systemFontOfSize:[fontSize floatValue]];
  17. }
  18. }
  19. return titleTextAttributes;
  20. }
  21. @end