iOS 更换其他第三方字体(TTF字体)
2020-10-15 本文已影响0人
唐人街的乞丐
更换其他第三方字体
第三方字体展示1、先下载TTF字体,下载下来的字体长下面这个样子
TTF字体2、配置PLIST文件 添加 Fonts provided by application字段,把需要配置的字体名字填进去
配置字体3、获取字体的名字,导入字体的名字跟系统识别的不一样
for (NSString *familyname in [UIFont familyNames])
{
NSLog(@"family = %@",familyname);
for(NSString *fontName in [UIFont fontNamesForFamilyName:familyname])
{
NSLog(@"fontName = %@",fontName);
}
NSLog(@"\n\n");
}
获取导入的字体的名字
family = ChanYuMengXinTi
fontName = CYMXT--GB1-0
family = FZZangYiHanTiS-R-GB
fontName = FZZYHTJW--GB1-0
family = FZHuangTingJianXingShuJF
fontName = FZHUANGTJXSJF--GBK1-0
4、使用
中文、英文大小写、数字都有显示
UILabel * topLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 100, 400, 120)];
topLabel.font = [UIFont fontWithName:@"CYMXT--GB1-0" size:18];
topLabel.numberOfLines = 0;
topLabel.text = @"qwertyuiop\nQWERTYUIOP\n0123456789\n唐人街的乞丐----更换字体";
[self.view addSubview:topLabel];
UILabel * midLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 250, 400, 120)];
midLabel.numberOfLines = 0;
midLabel.text = @"qwertyuiop\nQWERTYUIOP\n0123456789\n唐人街的乞丐----更换字体";
midLabel.font = [UIFont fontWithName:@"FZZYHTJW--GB1-0" size:18];
[self.view addSubview:midLabel];
UILabel * btmLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 400, 400, 120)];
btmLabel.numberOfLines = 0;
btmLabel.text = @"qwertyuiop\nQWERTYUIOP\n0123456789\n唐人街的乞丐----更换字体";
btmLabel.font = [UIFont fontWithName:@"FZHUANGTJXSJF--GBK1-0" size:18];
[self.view addSubview:btmLabel];
展示结果
字体显示样式