I am working on changing the font size of attributed and non attributed label texts.
I want to scan all the UIlabel
in my UIView
then based on whether they are attributed text holder I want to increase the font size of entire label while preserving the current font attributes like bold, italic, color etc.
if ([vv isKindOfClass:[UILabel class]])
{
UILabel *lbl = (UILabel *)vv;
NSDictionary *attributes = [(NSAttributedString *)lbl.attributedText
attributesAtIndex:0 effectiveRange:NULL];
if(attributes)
{
lbl.attributedText = [[NSAttributedString alloc] initWithString:lbl.text
attributes:attributes];
lbl.font=[UIFont fontWithDescriptor:[UIFontDescriptor
fontDescriptorWithFontAttributes:attributes]
size:lbl.font.pointSize+self.fontsize];
}
}
Using the below line of code I end up skipping the text attributes and it picks the very first font name and apply to the rest of string in label's text
lbl.font=[UIFont fontWithName:[lbl.font fontName] size:lbl.font.pointSize+self.fontsize];
I want to increase font size yet maintain the font attributes Any help will be appreciated Thanks