NSAttributedString投影在下行器上进行裁剪

时间:2013-05-14 16:15:45

标签: objective-c ios6

我在iOS6中使用NSMutableAttributedStringUILabel子类中应用字距调整和阴影。正确应用属性,但是阴影在第一个字符的左边缘和下行部分的底部进行裁剪(例如小写的p)。标签本身已禁用clipsToBounds

代码......

NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:[self text]];
NSRange range = NSMakeRange(0, [attributedString length]);

NSNumber *kern = [NSNumber numberWithFloat:0.75f];
[attributedString addAttribute:NSKernAttributeName value:kern range:range];

NSShadow *shadow = [[NSShadow alloc] init];
[shadow setShadowBlurRadius:3.0f];
[shadow setShadowColor:[UIColor darkGrayColor]];
[shadow setShadowOffset:CGSizeMake(0, 2.0f)];
[attributedString addAttribute:NSShadowAttributeName value:shadow range:range];

[self setAttributedText:attributedString];

它几乎没有引人注意,但一旦你看到它,它是显而易见的。有其他人遇到过这个错误并且有解决办法吗?

0 个答案:

没有答案