我正在寻找一种更简单的方法来设置NSFont的权重。
现在我只能这样做:
void SetWeight(NSFont font, int weight)
{
NSFontManager *manager = [NSFontManager sharedFontManager];
int currentWeight = [manager weightOfFont:font];
while( currentWeight != weight )
{
if( currentWeight >= weight )
{
[manager convertWeight:NO ofFont:font];
currentWeight--;
}
else
{
[manager convertWeight:YES ofFont:font];
currentWeight++;
}
}
}有没有更简单的方法来为NSFont设置适当的权重?具体来说,我正在寻找消除循环的方法
发布于 2015-06-11 18:09:32
NSFontManager中的这个方法适合这个目的吗?
- (NSFont *)fontWithFamily:(NSString *)family
traits:(NSFontTraitMask)fontTraitMask
weight:(NSInteger)weight
size:(CGFloat)size发布于 2017-02-26 03:47:24
例如,对于一个按钮
button.font = [NSFont systemFontOfSize:13 weight:NSFontWeightMedium];https://stackoverflow.com/questions/30771400
复制相似问题