BPKFont
@interface BPKFont : NSObject
BPKFont is the entry point for the Backpack typography stack. It expose the supported text styles as static methods.
-
Create a dictionary of attributes for a specific text styles. This is some times useful when building custom attributed strings is required.
Warning
Prefer using
BPKLabel,BPKTextField, orBPKTextViewfor rendering text when possible.Declaration
Objective-C
+ (nonnull NSDictionary<NSAttributedStringKey, id> *)attributesForFontStyle: (BPKFontStyle)fontStyle;Swift
class func makeAttributes(fontStyle: BPKFontStyle) -> [NSAttributedString.Key : Any]Parameters
fontStyleThe desired fontStyle.
Return Value
A dictionary of attributes describing the specified style.
-
Create a dictionary of attributes for a specific text styles. This is some times useful when building custom attributed strings is required.
Warning
Prefer using
BPKLabel,BPKTextField, orBPKTextViewfor rendering text when possible.Declaration
Objective-C
+ (nonnull NSDictionary<NSAttributedStringKey, id> *) attributesForFontStyle:(BPKFontStyle)fontStyle fontManager:(nonnull BPKFontManager *)fontManager;Swift
class func makeAttributes(fontStyle: BPKFontStyle, fontManager: BPKFontManager) -> [NSAttributedString.Key : Any]Parameters
fontStyleThe desired fontStyle.
fontManagerThe fontManager instance to use. By default this is
[BPKFontManager sharedInstance].Return Value
A dictionary of attributes describing the specified style.
-
Create a dictionary of attributes for a specific text styles. This is some times useful when building custom attributed strings is required.
Warning
Prefer using
BPKLabel,BPKTextField, orBPKTextViewfor rendering text when possible.Declaration
Objective-C
+ (nonnull NSDictionary<NSAttributedStringKey, id> *) attributesForFontStyle:(BPKFontStyle)fontStyle withCustomAttributes: (nonnull NSDictionary<NSAttributedStringKey, id> *)customAttributes;Swift
class func makeAttributes(fontStyle: BPKFontStyle, customAttributes: [NSAttributedString.Key : Any] = [:]) -> [NSAttributedString.Key : Any]Parameters
fontStyleThe desired fontStyle.
customAttributesAdditional attributes to include in the result. Attributes that would break the Backpack type rendering are ignored.
Return Value
A dictionary of attributes describing the specified style and custom attributes.
-
Create an attributed string with a specified fontStyle and content. The default Backpack text color will be used.
Warning
Prefer using
BPKLabel,BPKTextField, orBPKTextViewfor rendering text when possible.Declaration
Objective-C
+ (nonnull NSAttributedString *) attributedStringWithFontStyle:(BPKFontStyle)fontStyle content:(nonnull NSString *)content;Swift
class func makeAttributedString(fontStyle: BPKFontStyle, content: String) -> NSAttributedStringParameters
fontStyleThe desired fontStyle.
contentThe content of the attributedString.
Return Value
An attributed string with the specified styles.
-
Create an attributed string with a specified fontStyle, content, and text color.
Warning
Prefer using
BPKLabel,BPKTextField, orBPKTextViewfor rendering text when possible.Declaration
Objective-C
+ (nonnull NSAttributedString *) attributedStringWithFontStyle:(BPKFontStyle)fontStyle content:(nonnull NSString *)content textColor:(nonnull UIColor *)textColor;Swift
class func makeAttributedString(fontStyle: BPKFontStyle, content: String, textColor: Any!) -> NSAttributedStringParameters
fontStyleThe desired fontStyle.
contentThe content of the attributedString.
textColorThe text color to use.
Return Value
An attributed string with the specified styles.
-
Set the fontfaces to use globally.
Declaration
Objective-C
+ (void)setFontDefinition: (id<BPKFontDefinitionProtocol> _Nullable)fontDefinition;Parameters
fontDefinitionThe new font definition to use when resolving fontface names.
-
Create a
UIFontinstance for a specific text style.Warning
Prefer using
BPKLabel,BPKTextField, orBPKTextViewfor rendering text when possible.Declaration
Objective-C
+ (nonnull UIFont *)fontForFontStyle:(BPKFontStyle)fontStyle;Swift
class func makeFont(fontStyle: BPKFontStyle) -> UIFontParameters
fontStyleThe desired fontStyle.
Return Value
An instance of
UIFontfor the specificed style.
BPKFont Class Reference