1.先用下面代码查看字体种类
- (void)enumerateFonts{
NSArray *familyNames =[[NSArray alloc]initWithArray:[UIFont familyNames]];
NSArray *fontNames;
NSInteger indFamily, indFont;
NSLog(@"[familyNames count]===%lu",(unsigned long)[familyNames count]);
for(indFamily=0;indFamily<[familyNames count];++indFamily)
{
NSLog(@"Family name: %@", [familyNames objectAtIndex:indFamily]);
fontNames =[[NSArray alloc]initWithArray:[UIFont fontNamesForFamilyName:[familyNames objectAtIndex:indFamily]]];
for(indFont=0; indFont<[fontNames count]; ++indFont)
{
NSLog(@"Font name: %@",[fontNames objectAtIndex:indFont]);
}
}
}
2.设置Font类型
lab1.font = [UIFont fontWithName:@"PingFang SC" size:20];
或者
lab1.font = [UIFont fontWithName:@"PingFang SC-Light" size:20];