我在设置 this 时的范围(我认为)有问题NSMutableAttributedString
。谁能告诉我为什么这会使我的程序崩溃?在我看来是对的,但我显然错了!谢谢。
NSString *placeHolderString = @"USERNAME";
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] init];
float spacing = 5.0f;
// crashes on this line
[attributedString addAttribute:NSKernAttributeName
value:@(spacing)
range:NSMakeRange(0, [placeHolderString length])];
self.userNameTextField.attributedPlaceholder = attributedString;