gpt4 book ai didi

iphone - CTFontRef 存在问题

转载 作者:行者123 更新时间:2023-11-29 04:45:09 41 4
gpt4 key购买 nike

您好,我需要在 iPad 应用程序中使用几种带有 CTFontRef 的字体,我需要使用此方法,因为我的字体不是英文。所以我从这个site找到了这段代码

但是编译器给了我一些错误:

CTFontRef font = CTFontCreateWithName(CFSTR("myfont"), 12,NULL);

NSMutableAttributedStringRef attrString = [[NSMutableAttributedString alloc] initWithString:textView.text];
[attrString addAttribute:(NSString*)kCTFontAttributeName
value:(id)font
range: NSMakeRange(0, textView.text.length)];

enter image description here

如果您能帮我解决问题,我将不胜感激

最佳答案

看看这个。可能对你有用:

CTFontRef font = CTFontCreateWithName(CFSTR("GujaratiSangamMN-Bold"),12.0f, NULL);
NSDictionary *attrs = [NSDictionary dictionaryWithObjectsAndKeys:
(id)font, kCTFontAttributeName,
nil];
NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:textView.text
attributes:attrs];

关于iphone - CTFontRef 存在问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9767178/

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