我正在开发一个iPhone应用程序,我想在UILabel中设置字距.我写的代码(可能在附近kCTKernAttributeName
)似乎是错误的.我该如何解决这个问题呢?
NSMutableAttributedString *attStr;
NSString *str = @"aaaaaaa";
CFStringRef kern = kCTKernAttributeName;
NSNumber *num = [NSNumber numberWithFloat: 2.0f];
NSDictionary *attributesDict = [NSDictionary dictionaryWithObject:num
forKey:(NSString*)kern];
[attStr initWithString:str attributes:attributesDict];
CGRect frame1 = CGRectMake(0, 0, 100, 40);
UILabel *label1 = [[UILabel alloc] initWithFrame:frame1];
label1.text = attStr
[self.view addSubview:label1];
Run Code Online (Sandbox Code Playgroud) 我已经在互联网上搜索了一段时间,以获取有关如何改变UIKit中字体的字母间距/字距调整的信息.
我担心的是,就像使用自己的自定义字体一样,你根本就不能.这将是一个可怕的消息.
我知道Apple正在通过这些限制来保护我们免受糟糕的设计,但它们也阻止我们实现真正优秀的设计.
人们建议我做什么?
使用带有标准字距调整的字体,人们可能不会注意到差异.
找到某人的黑客课程,以便在与他们辛苦赚来的现金分手后获得用户应得的外观.
使用我忽略的方法,并与UIKit一起做,承诺永远感谢那个赋予这隐藏的知识金块的人.
iphone cocoa-touch core-graphics objective-c quartz-graphics