2
커닝을 변경하는 속성이없는 것 같습니다. C4Label에서 UILabel을 가져 와서 거기에서 가장 좋은 방법입니까?C4Label 커닝을 어떻게 조정합니까?
커닝을 변경하는 속성이없는 것 같습니다. C4Label에서 UILabel을 가져 와서 거기에서 가장 좋은 방법입니까?C4Label 커닝을 어떻게 조정합니까?
불행히도 그렇습니다.
C4Label
은 원래 iOS5가 출시 될 때 설계되었으며 iOS6이 출시 될 때 수정이 필요하지 않았습니다 ... iOS6 이전에는 속성 문자열 사용이 UILabel
에서 불가능했습니다. C4Label
은 본질적으로 UILabel
의 인스턴스를 래핑하므로 속성 문자열 사용에 직접 액세스 할 수 없었습니다.
-(void)setup {
//Create a label
C4Label *l = [C4Label labelWithText:@"this is kerning"];
l.numberOfLines = 2;
//Create a key
NSString *kernKey = (NSString *)kCTKernAttributeName;
//Create a value
NSNumber *kernValue = @20;
//Create an attributed string
NSMutableAttributedString *attStr = [NSMutableAttributedString new];
//set the attributed string with the text, using the value as a dictionary
attStr = [attStr initWithString:l.text attributes:@{kernKey:kernValue}];
//set and center the text
l.label.attributedText = attStr;
l.textAlignment = ALIGNTEXTCENTER;
//resize and position the frame
l.frame = CGRectMake(0,0,320, 80);
l.center = self.canvas.center;
[self.canvas addLabel:l];
}
C4Label은 현대화에 대한 목록에 있지만 아직에 입수되지 않았습니다
는 그러나 C4Label
랩을 부여 UILabel
는 다음과 같은 방법으로 커닝을 추가 할 수 있습니다.