gpt4 book ai didi

ios - 加粗 nsstring

转载 作者:行者123 更新时间:2023-11-28 21:34:23 28 4
gpt4 key购买 nike

我在网上寻找加粗 NSString 的方法,但它要么不存在,要么我似乎找不到。我只是想在 NSString 中加粗这个词,但到目前为止,我所做的还没有实现:

 NSString *player1Name = [[UIFont boldSystemFontOfSize:12] fontName];

我依靠它使“player1Name”变为粗体,但它根本不起作用。当我运行它时,我得到这个:

enter image description here

提前感谢任何帮助我找出解决方案的人。

最佳答案

你不能加粗 NSString...试试 NSAttributedString...

NSAttributedString *player1Name = [[NSAttributedString alloc] initWithString:@"name" attributes:@{NSFontAttributeName : [UIFont boldSystemFontOfSize:12]}];

https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSAttributedString_Class/

fontName 是 UIFont 上的一个属性

[[UIFont boldSystemFontOfSize:12] fontName]

返回字体名称HelveticaNeueInterface-MediumP4

关于ios - 加粗 nsstring,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34505451/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com