NSAttributedString shadow shadow - crop on descenders

I am using NSMutableAttributedString in iOS6 to apply kerning and casting shadows in a subclass of UILabel . Attributes are applied correctly, but the shadow of quotation marks is trimmed on the left edge of the first character and the bottom of the descriptors (for example, lowercase). The shortcut itself is disabled clipsToBounds .

Code...

 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]; 

It is barely noticeable, but as soon as you see it, it is obvious. Others have this error, and is there a job?

+6
source share

Source: https://habr.com/ru/post/944995/


All Articles