iOS中如何使用iconfont图标实例详解

2020-01-21 06:55:34于丽

iOS,iconfont,图标

在plist文件中加入字体

iOS,iconfont,图标

接下来我们借助淘点点科技写的一个关于iconfont封装,方便我们使用iconfont。iconfont的封装包括

iOS,iconfont,图标
工具类

TBCityIconInfo.h的实现


#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

@interface TBCityIconInfo : NSObject

@property (nonatomic, strong) NSString *text;
@property (nonatomic, assign) NSInteger size;
@property (nonatomic, strong) UIColor *color;

- (instancetype)initWithText:(NSString *)text size:(NSInteger)size color:(UIColor *)color;
+ (instancetype)iconInfoWithText:(NSString *)text size:(NSInteger)size color:(UIColor *)color;

@end

TBCityIconInfo.m的实现


#import "TBCityIconInfo.h"

@implementation TBCityIconInfo

- (instancetype)initWithText:(NSString *)text size:(NSInteger)size color:(UIColor *)color {
 if (self = [super init]) {
  self.text = text;
  self.size = size;
  self.color = color;
 }
 return self;
}

+ (instancetype)iconInfoWithText:(NSString *)text size:(NSInteger)size color:(UIColor *)color {
 return [[TBCityIconInfo alloc] initWithText:text size:size color:color];
}

@end