无论如何使用Interface Builder更改UILabel文本上的字符间距(轨道)?如果没有,有没有办法在已经使用属性文本创建的现有UILabel上以编程方式执行此操作?
我正在开发一个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)