Tuesday, 27 August 2013

Check the text Font is "Bold" or "Italic" UIFont.



Import CoreTextFrameWork.

#import <CoreText/CoreText.h>


+(BOOL)isBold
{
    CTFontRef fontRef = (__bridge CTFontRef)self;
    CTFontSymbolicTraits symbolicTraits = CTFontGetSymbolicTraits(fontRef);
    return (symbolicTraits & kCTFontBoldTrait);
}

+(BOOL)isItalic
{
    CTFontRef fontRef = (__bridge CTFontRef)self;
    CTFontSymbolicTraits symbolicTraits = CTFontGetSymbolicTraits(fontRef);
    return (symbolicTraits & kCTFontItalicTrait);
}

No comments:

Post a Comment