小编kz0*_*011的帖子

如何在iPhone 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)

cocoa-touch uilabel kerning ios

32
推荐指数
6
解决办法
3万
查看次数

标签 统计

cocoa-touch ×1

ios ×1

kerning ×1

uilabel ×1