add new fonts method,

change font from nullable to non null for better swift typing
This commit is contained in:
Xinlei(Ryan) Pan 2020-02-25 13:59:24 -05:00
parent 4ad4eb7f46
commit 455507626c
5 changed files with 695 additions and 6 deletions

View File

@ -132,6 +132,89 @@ public typealias ActionBlock = () -> ()
// MARK: - Factory Functions
//------------------------------------------------------
/// Title 2XLarge
@objc public static func commonLabelTitle2XLarge(_ scale: Bool) -> Label {
let label = Label.label()
label.styleTitle2XLarge(scale)
return label
}
/// TitleXLarge
@objc public static func commonLabelTitleXLarge(_ scale: Bool) -> Label {
let label = Label.label()
label.styleTitleXLarge(scale)
return label
}
/// BoldTitleLarge
@objc public static func commonLabelBoldTitleLarge(_ scale: Bool) -> Label {
let label = Label.label()
label.styleBoldTitleLarge(scale)
return label
}
/// RegularTitleLarge
@objc public static func commonLabelRegularTitleLarge(_ scale: Bool) -> Label {
let label = Label.label()
label.styleRegularTitleLarge(scale)
return label
}
/// BoldTitleMedium
@objc public static func commonLabelBoldTitleMedium(_ scale: Bool) -> Label {
let label = Label.label()
label.styleBoldTitleMedium(scale)
return label
}
/// RegularTitleMedium
@objc public static func commonLabelRegularTitleMedium(_ scale: Bool) -> Label {
let label = Label.label()
label.styleRegularTitleMedium(scale)
return label
}
/// BoldBodyLarge
@objc public static func commonLabelBoldBodyLarge(_ scale: Bool) -> Label {
let label = Label.label()
label.styleBoldBodyLarge(scale)
return label
}
/// RegularBodyLarge
@objc public static func commonLabelRegularBodyLarge(_ scale: Bool) -> Label {
let label = Label.label()
label.styleRegularBodyLarge(scale)
return label
}
/// BoldBodySmall
@objc public static func commonLabelBoldBodySmall(_ scale: Bool) -> Label {
let label = Label.label()
label.styleBoldBodySmall(scale)
return label
}
/// RegularBodySmall
@objc public static func commonLabelRegularBodySmall(_ scale: Bool) -> Label {
let label = Label.label()
label.styleRegularBodySmall(scale)
return label
}
/// BoldMicro
@objc public static func commonLabelBoldMicro(_ scale: Bool) -> Label {
let label = Label.label()
label.styleBoldMicro(scale)
return label
}
/// RegularMicro
@objc public static func commonLabelRegularMicro(_ scale: Bool) -> Label {
let label = Label.label()
label.styleRegularMicro(scale)
return label
}
//2.0 fonts init methods
/// H1 -> HeadlineLarge
@objc public static func commonLabelH1(_ scale: Bool) -> Label {
let label = Label.label()
@ -481,6 +564,68 @@ public typealias ActionBlock = () -> ()
// MARK: - Methods
//------------------------------------------------------
//mva 3.0 font
@objc public func styleTitle2XLarge(_ scale: Bool) {
MFStyler.styleLabelTitle2XLarge(self, genericScaling: false)
setScale(scale)
}
@objc public func styleTitleXLarge(_ scale: Bool) {
MFStyler.styleLabelTitleXLarge(self, genericScaling: false)
setScale(scale)
}
@objc public func styleBoldTitleLarge(_ scale: Bool) {
MFStyler.styleLabelBoldTitleLarge(self, genericScaling: false)
setScale(scale)
}
@objc public func styleRegularTitleLarge(_ scale: Bool) {
MFStyler.styleLabelRegularTitleLarge(self, genericScaling: false)
setScale(scale)
}
@objc public func styleBoldTitleMedium(_ scale: Bool) {
MFStyler.styleLabelBoldTitleMedium(self, genericScaling: false)
setScale(scale)
}
@objc public func styleRegularTitleMedium(_ scale: Bool) {
MFStyler.styleLabelRegularTitleMedium(self, genericScaling: false)
setScale(scale)
}
@objc public func styleBoldBodyLarge(_ scale: Bool) {
MFStyler.styleLabelBoldBodyLarge(self, genericScaling: false)
setScale(scale)
}
@objc public func styleRegularBodyLarge(_ scale: Bool) {
MFStyler.styleLabelRegularBodyLarge(self, genericScaling: false)
setScale(scale)
}
@objc public func styleBoldBodySmall(_ scale: Bool) {
MFStyler.styleLabelBoldBodySmall(self, genericScaling: false)
setScale(scale)
}
@objc public func styleRegularBodySmall(_ scale: Bool) {
MFStyler.styleLabelRegularBodySmall(self, genericScaling: false)
setScale(scale)
}
@objc public func styleBoldMicro(_ scale: Bool) {
MFStyler.styleLabelBoldMicro(self, genericScaling: false)
setScale(scale)
}
@objc public func styleRegularMicro(_ scale: Bool) {
MFStyler.styleLabelRegularMicro(self, genericScaling: false)
setScale(scale)
}
//2.0 fonts
@objc public func styleH1(_ scale: Bool) {
MFStyler.styleLabelH1(self, genericScaling: false)
setScale(scale)

View File

@ -98,6 +98,46 @@ B3 -> Legal
//-------------------------------------------------
// Returns the fonts for these styles. Scales them as needed by default
#pragma mark - 3.0 fonts
///Bold 36pt
+ (nonnull UIFont *)fontTitle2XLarge:(BOOL)genericScaling;
+ (nonnull UIFont *)fontTitle2XLarge;
///Bold 32pt
+ (nonnull UIFont *)fontTitleXLarge:(BOOL)genericScaling;
+ (nonnull UIFont *)fontTitleXLarge;
///Bold 24pt
+ (nonnull UIFont *)fontBoldTitleLarge:(BOOL)genericScaling;
+ (nonnull UIFont *)fontBoldTitleLarge;
///Regular 24pt
+ (nonnull UIFont *)fontRegularTitleLarge:(BOOL)genericScaling;
+ (nonnull UIFont *)fontRegularTitleLarge;
///Bold 20pt
+ (nonnull UIFont *)fontBoldTitleMedium:(BOOL)genericScaling;
+ (nonnull UIFont *)fontBoldTitleMedium;
///Regular 20pt
+ (nonnull UIFont *)fontRegularTitleMedium:(BOOL)genericScaling;
+ (nonnull UIFont *)fontRegularTitleMedium;
///Bold 16pt
+ (nonnull UIFont *)fontBoldBodyLarge:(BOOL)genericScaling;
+ (nonnull UIFont *)fontBoldBodyLarge;
///Regular 16pt
+ (nonnull UIFont *)fontRegularBodyLarge:(BOOL)genericScaling;
+ (nonnull UIFont *)fontRegularBodyLarge;
///Bold 13pt
+ (nonnull UIFont *)fontBoldBodySmall:(BOOL)genericScaling;
+ (nonnull UIFont *)fontBoldBodySmall;
///Regular 13pt
+ (nonnull UIFont *)fontRegularBodySmall:(BOOL)genericScaling;
+ (nonnull UIFont *)fontRegularBodySmall;
///Bold 11pt
+ (nonnull UIFont *)fontBoldMicro:(BOOL)genericScaling;
+ (nonnull UIFont *)fontBoldMicro;
///Regular 11pt
+ (nonnull UIFont *)fontRegularMicro:(BOOL)genericScaling;
+ (nonnull UIFont *)fontRegularMicro;
#pragma mark - 2.0 fonts
//75Bd 40pt
@ -206,9 +246,50 @@ B3 -> Legal
//-------------------------------------------------
// Applies the styles to the passed in objects.
#pragma mark - 3.0 Styles
+ (void)styleLabelTitle2XLarge:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling;
+ (void)styleLabelTitle2XLarge:(nonnull UILabel *)label;
+ (void)styleLabelTitleXLarge:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling;
+ (void)styleLabelTitleXLarge:(nonnull UILabel *)label;
+ (void)styleLabelBoldTitleLarge:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling;
+ (void)styleLabelBoldTitleLarge:(nonnull UILabel *)label;
+ (void)styleLabelRegularTitleLarge:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling;
+ (void)styleLabelRegularTitleLarge:(nonnull UILabel *)label;
+ (void)styleLabelBoldTitleMedium:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling;
+ (void)styleLabelBoldTitleMedium:(nonnull UILabel *)label;
+ (void)styleLabelRegularTitleMedium:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling;
+ (void)styleLabelRegularTitleMedium:(nonnull UILabel *)label;
+ (void)styleLabelBoldBodyLarge:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling;
+ (void)styleLabelBoldBodyLarge:(nonnull UILabel *)label;
+ (void)styleLabelRegularBodyLarge:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling;
+ (void)styleLabelRegularBodyLarge:(nonnull UILabel *)label;
+ (void)styleLabelBoldBodySmall:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling;
+ (void)styleLabelBoldBodySmall:(nonnull UILabel *)label;
+ (void)styleLabelRegularBodySmall:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling;
+ (void)styleLabelRegularBodySmall:(nonnull UILabel *)label;
+ (void)styleLabelBoldMicro:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling;
+ (void)styleLabelBoldMicro:(nonnull UILabel *)label;
+ (void)styleLabelRegularMicro:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling;
+ (void)styleLabelRegularMicro:(nonnull UILabel *)label;
/// Will style the label with mva 3.0 fonts based on the string.
+ (BOOL)styleMVA3Label:(nonnull UILabel *)label withStyle:(nullable NSString *)style genericScaling:(BOOL)genericScaling;
#pragma mark - 2.0 styles
/// Will style the label based on the string. Accepted values, H1, H2, H3, H32, B1, B2, B3, B20
/// Will style the label based on the string. Accepted values, including mva3.0 fonts and 2.0 fonts H1, H2, H3, H32, B1, B2, B3, B20
+ (void)styleLabel:(nonnull UILabel *)label withStyle:(nullable NSString *)style;
+ (void)styleLabel:(nonnull UILabel *)label withStyle:(nullable NSString *)style genericScaling:(BOOL)genericScaling;
@ -257,6 +338,43 @@ B3 -> Legal
#pragma mark - Attributed Strings
+ (nonnull NSAttributedString *)styleGetTitle2XLargeAttributedString:(nullable NSString *)string;
+ (nonnull NSAttributedString *)styleGetTitle2XLargeAttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling;
+ (nonnull NSAttributedString *)styleGetTitleXLargeAttributedString:(nullable NSString *)string;
+ (nonnull NSAttributedString *)styleGetTitleXLargeAttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling;
+ (nonnull NSAttributedString *)styleGetBoldTitleLargeAttributedString:(nullable NSString *)string;
+ (nonnull NSAttributedString *)styleGetBoldTitleLargeAttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling;
+ (nonnull NSAttributedString *)styleGetRegularTitleLargeAttributedString:(nullable NSString *)string;
+ (nonnull NSAttributedString *)styleGetRegularTitleLargeAttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling;
+ (nonnull NSAttributedString *)styleGetBoldTitleMediumAttributedString:(nullable NSString *)string;
+ (nonnull NSAttributedString *)styleGetBoldTitleMediumAttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling;
+ (nonnull NSAttributedString *)styleGetRegularTitleMediumAttributedString:(nullable NSString *)string;
+ (nonnull NSAttributedString *)styleGetRegularTitleMediumAttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling;
+ (nonnull NSAttributedString *)styleGetBoldBodyLargeAttributedString:(nullable NSString *)string;
+ (nonnull NSAttributedString *)styleGetBoldBodyLargeAttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling;
+ (nonnull NSAttributedString *)styleGetRegularBodyLargeAttributedString:(nullable NSString *)string;
+ (nonnull NSAttributedString *)styleGetRegularBodyLargeAttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling;
+ (nonnull NSAttributedString *)styleGetBoldBodySmallAttributedString:(nullable NSString *)string;
+ (nonnull NSAttributedString *)styleGetBoldBodySmallAttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling;
+ (nonnull NSAttributedString *)styleGetRegularBodySmallAttributedString:(nullable NSString *)string;
+ (nonnull NSAttributedString *)styleGetRegularBodySmallAttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling;
+ (nonnull NSAttributedString *)styleGetBoldMicroAttributedString:(nullable NSString *)string;
+ (nonnull NSAttributedString *)styleGetBoldMicroAttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling;
+ (nonnull NSAttributedString *)styleGetRegularMicroAttributedString:(nullable NSString *)string;
+ (nonnull NSAttributedString *)styleGetRegularMicroAttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling;
/// Will style the string based on the string. Accepted values, H1, H2, H3, H32, B1, B2, B3, B20
+ (nonnull NSAttributedString *)styleGetAttributedString:(nullable NSString *)string withStyle:(nullable NSString *)style;
+ (nonnull NSAttributedString *)styleGetAttributedString:(nullable NSString *)string withStyle:(nullable NSString *)style genericScaling:(BOOL)genericScaling;

View File

@ -111,6 +111,152 @@ CGFloat const LabelWithInternalButtonLineSpace = 2;
}];
}
#pragma mark - 3.0 fonts
+ (nonnull UIFont *)fontTitle2XLarge:(BOOL)genericScaling {
CGFloat size = 36;
if (genericScaling) {
size = [self sizeFontGenericForCurrentDevice:size];
}
return [MFFonts mfFont75Bd:size];
}
+ (nonnull UIFont *)fontTitle2XLarge {
return [self fontTitle2XLarge:YES];
}
+ (nonnull UIFont *)fontTitleXLarge:(BOOL)genericScaling {
CGFloat size = 32;
if (genericScaling) {
size = [self sizeFontGenericForCurrentDevice:size];
}
return [MFFonts mfFont75Bd:size];
}
+ (nonnull UIFont *)fontTitleXLarge{
return [self fontTitleXLarge:YES];
}
+ (nonnull UIFont *)fontBoldTitleLarge:(BOOL)genericScaling {
CGFloat size = 24;
if (genericScaling) {
size = [self sizeFontGenericForCurrentDevice:size];
}
return [MFFonts mfFont75Bd:size];
}
+ (nonnull UIFont *)fontBoldTitleLarge {
return [self fontBoldTitleLarge:YES];
}
+ (nonnull UIFont *)fontRegularTitleLarge:(BOOL)genericScaling {
CGFloat size = 24;
if (genericScaling) {
size = [self sizeFontGenericForCurrentDevice:size];
}
return [MFFonts mfFont55Rg:size];
}
+ (nonnull UIFont *)fontRegularTitleLarge {
return [self fontRegularTitleLarge:YES];
}
+ (nonnull UIFont *)fontBoldTitleMedium:(BOOL)genericScaling {
CGFloat size = 20;
if (genericScaling) {
size = [self sizeFontGenericForCurrentDevice:size];
}
return [MFFonts mfFont75Bd:size];
}
+ (nonnull UIFont *)fontBoldTitleMedium {
return [self fontBoldTitleMedium:YES];
}
+ (nonnull UIFont *)fontRegularTitleMedium:(BOOL)genericScaling {
CGFloat size = 20;
if (genericScaling) {
size = [self sizeFontGenericForCurrentDevice:size];
}
return [MFFonts mfFont55Rg:size];
}
+ (nonnull UIFont *)fontRegularTitleMedium {
return [self fontRegularTitleMedium:YES];
}
+ (nonnull UIFont *)fontBoldBodyLarge:(BOOL)genericScaling {
CGFloat size = 16;
if (genericScaling) {
size = [self sizeFontGenericForCurrentDevice:size];
}
return [MFFonts mfFont75Bd:size];
}
+ (nonnull UIFont *)fontBoldBodyLarge {
return [self fontBoldBodyLarge:YES];
}
+ (nonnull UIFont *)fontRegularBodyLarge:(BOOL)genericScaling {
CGFloat size = 16;
if (genericScaling) {
size = [self sizeFontGenericForCurrentDevice:size];
}
return [MFFonts mfFont55Rg:size];
}
+ (nonnull UIFont *)fontRegularBodyLarge {
return [self fontRegularBodyLarge:YES];
}
+ (nonnull UIFont *)fontBoldBodySmall:(BOOL)genericScaling {
CGFloat size = 13;
if (genericScaling) {
size = [self sizeFontGenericForCurrentDevice:size];
}
return [MFFonts mfFont75Bd:size];
}
+ (nonnull UIFont *)fontBoldBodySmall {
return [self fontBoldBodySmall:YES];
}
+ (nonnull UIFont *)fontRegularBodySmall:(BOOL)genericScaling {
CGFloat size = 13;
if (genericScaling) {
size = [self sizeFontGenericForCurrentDevice:size];
}
return [MFFonts mfFont55Rg:size];
}
+ (nonnull UIFont *)fontRegularBodySmall {
return [self fontRegularBodySmall:YES];
}
+ (nonnull UIFont *)fontBoldMicro:(BOOL)genericScaling {
CGFloat size = 11;
if (genericScaling) {
size = [self sizeFontGenericForCurrentDevice:size];
}
return [MFFonts mfFont75Bd:size];
}
+ (nonnull UIFont *)fontBoldMicro {
return [self fontBoldMicro:YES];
}
+ (nonnull UIFont *)fontRegularMicro:(BOOL)genericScaling {
CGFloat size = 11;
if (genericScaling) {
size = [self sizeFontGenericForCurrentDevice:size];
}
return [MFFonts mfFont55Rg:size];
}
+ (nonnull UIFont *)fontRegularMicro {
return [self fontRegularMicro:YES];
}
#pragma mark - 2.0 fonts
+ (nullable UIFont *)fontH1:(BOOL)genericScaling {
@ -514,10 +660,165 @@ CGFloat const LabelWithInternalButtonLineSpace = 2;
return [MFFonts mfFont55Rg:[self sizeFontGenericForCurrentDevice:size]];
}
#pragma mark - 3.0 Styles
+ (void)styleLabelTitle2XLarge:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling {
label.font = [MFStyler fontTitle2XLarge:genericScaling];
label.textColor = [UIColor blackColor];
}
+ (void)styleLabelTitle2XLarge:(nonnull UILabel *)label {
[self styleLabelTitle2XLarge:label genericScaling:YES];
}
+ (void)styleLabelTitleXLarge:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling {
label.font = [MFStyler fontTitleXLarge:genericScaling];
label.textColor = [UIColor blackColor];
}
+ (void)styleLabelTitleXLarge:(nonnull UILabel *)label {
[self styleLabelTitleXLarge:label genericScaling:YES];
}
+ (void)styleLabelBoldTitleLarge:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling {
label.font = [MFStyler fontBoldTitleLarge:genericScaling];
label.textColor = [UIColor blackColor];
}
+ (void)styleLabelBoldTitleLarge:(nonnull UILabel *)label {
[self styleLabelBoldTitleLarge:label genericScaling:YES];
}
+ (void)styleLabelRegularTitleLarge:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling {
label.font = [MFStyler fontRegularTitleLarge:genericScaling];
label.textColor = [UIColor blackColor];
}
+ (void)styleLabelRegularTitleLarge:(nonnull UILabel *)label {
[self styleLabelBoldTitleLarge:label genericScaling:YES];
}
+ (void)styleLabelBoldTitleMedium:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling {
label.font = [MFStyler fontBoldTitleMedium:genericScaling];
label.textColor = [UIColor blackColor];
}
+ (void)styleLabelBoldTitleMedium:(nonnull UILabel *)label {
[self styleLabelBoldTitleMedium:label genericScaling:YES];
}
+ (void)styleLabelRegularTitleMedium:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling {
label.font = [MFStyler fontRegularTitleMedium:genericScaling];
label.textColor = [UIColor blackColor];
}
+ (void)styleLabelRegularTitleMedium:(nonnull UILabel *)label {
[self styleLabelRegularTitleMedium:label genericScaling:YES];
}
+ (void)styleLabelBoldBodyLarge:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling {
label.font = [MFStyler fontBoldBodyLarge:genericScaling];
label.textColor = [UIColor blackColor];
}
+ (void)styleLabelBoldBodyLarge:(nonnull UILabel *)label {
[self styleLabelBoldBodyLarge:label genericScaling:YES];
}
+ (void)styleLabelRegularBodyLarge:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling {
label.font = [MFStyler fontRegularBodyLarge:genericScaling];
label.textColor = [UIColor blackColor];
}
+ (void)styleLabelRegularBodyLarge:(nonnull UILabel *)label {
[self styleLabelRegularBodyLarge:label genericScaling:YES];
}
+ (void)styleLabelBoldBodySmall:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling {
label.font = [MFStyler fontBoldBodySmall:genericScaling];
label.textColor = [UIColor blackColor];
}
+ (void)styleLabelBoldBodySmall:(nonnull UILabel *)label {
[self styleLabelBoldBodySmall:label genericScaling:YES];
}
+ (void)styleLabelRegularBodySmall:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling {
label.font = [MFStyler fontRegularBodySmall:genericScaling];
label.textColor = [UIColor blackColor];
}
+ (void)styleLabelRegularBodySmall:(nonnull UILabel *)label {
[self styleLabelRegularBodySmall:label genericScaling:YES];
}
+ (void)styleLabelBoldMicro:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling {
label.font = [MFStyler fontBoldMicro:genericScaling];
label.textColor = [UIColor blackColor];
}
+ (void)styleLabelBoldMicro:(nonnull UILabel *)label {
[self styleLabelBoldMicro:label genericScaling:YES];
}
+ (void)styleLabelRegularMicro:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling {
label.font = [MFStyler fontRegularMicro:genericScaling];
label.textColor = [UIColor blackColor];
}
+ (void)styleLabelRegularMicro:(nonnull UILabel *)label {
[self styleLabelRegularMicro:label genericScaling:YES];
}
+ (BOOL)styleMVA3Label:(nonnull UILabel *)label withStyle:(nullable NSString *)style genericScaling:(BOOL)genericScaling {
if ([style isEqualToString:@"Title2XLarge"]) {
[self styleLabelTitle2XLarge:label genericScaling:genericScaling];
return YES;
} else if ([style isEqualToString:@"TitleXLarge"]) {
[self styleLabelTitleXLarge:label genericScaling:genericScaling];
return YES;
} else if ([style isEqualToString:@"BoldTitleLarge"]) {
[self styleLabelBoldTitleLarge:label genericScaling:genericScaling];
return YES;
} else if ([style isEqualToString:@"RegularTitleLarge"]) {
[self styleLabelRegularTitleLarge:label genericScaling:genericScaling];
return YES;
} else if ([style isEqualToString:@"BoldTitleMedium"]) {
[self styleLabelBoldTitleMedium:label genericScaling:genericScaling];
return YES;
} else if ([style isEqualToString:@"RegularTitleMedium"]) {
[self styleLabelRegularTitleMedium:label genericScaling:genericScaling];
return YES;
} else if ([style isEqualToString:@"BoldBodyLarge"]) {
[self styleLabelBoldBodyLarge:label genericScaling:genericScaling];
return YES;
} else if ([style isEqualToString:@"RegularBodyLarge"]) {
[self styleLabelRegularBodyLarge:label genericScaling:genericScaling];
return YES;
} else if ([style isEqualToString:@"BoldBodySmall"]) {
[self styleLabelBoldBodySmall:label genericScaling:genericScaling];
return YES;
} else if ([style isEqualToString:@"RegularBodySmall"]) {
[self styleLabelRegularBodySmall:label genericScaling:genericScaling];
return YES;
} else if ([style isEqualToString:@"BoldMicro"]) {
[self styleLabelBoldMicro:label genericScaling:genericScaling];
return YES;
} else if ([style isEqualToString:@"RegularMicro"]) {
[self styleLabelRegularMicro:label genericScaling:genericScaling];
return YES;
} else {
return NO;
}
}
#pragma mark - 2.0 Styles
+ (void)styleLabel:(nonnull UILabel *)label withStyle:(nullable NSString *)style genericScaling:(BOOL)genericScaling {
if ([style isEqualToString:@"H1"]) {
if ([self styleMVA3Label:label withStyle:style genericScaling:genericScaling]) {
//try mva 3.0 font first
} else if ([style isEqualToString:@"H1"]) {
[self styleLabelH1:label genericScaling:genericScaling];
} else if ([style isEqualToString:@"H2"]) {
[self styleLabelH2:label genericScaling:genericScaling];
@ -697,6 +998,105 @@ CGFloat const LabelWithInternalButtonLineSpace = 2;
return attributedString;
}
+ (nonnull NSAttributedString *)styleGetTitle2XLargeAttributedString:(nullable NSString *)string {
return [MFStyler styleGetTitle2XLargeAttributedString:string genericScaling:YES];
}
+ (nonnull NSAttributedString *)styleGetTitle2XLargeAttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling; {
return [MFStyler styleGetAttributedString:string font:[MFStyler fontTitle2XLarge:genericScaling] color:[UIColor blackColor]];
}
+ (nonnull NSAttributedString *)styleGetTitleXLargeAttributedString:(nullable NSString *)string {
return [MFStyler styleGetTitleXLargeAttributedString:string genericScaling:YES];
}
+ (nonnull NSAttributedString *)styleGetTitleXLargeAttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling {
return [MFStyler styleGetAttributedString:string font:[MFStyler fontTitleXLarge:genericScaling] color:[UIColor blackColor]];
}
+ (nonnull NSAttributedString *)styleGetBoldTitleLargeAttributedString:(nullable NSString *)string {
return [MFStyler styleGetBoldTitleLargeAttributedString:string genericScaling:YES];
}
+ (nonnull NSAttributedString *)styleGetBoldTitleLargeAttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling {
return [MFStyler styleGetAttributedString:string font:[MFStyler fontBoldTitleLarge:genericScaling] color:[UIColor blackColor]];
}
+ (nonnull NSAttributedString *)styleGetRegularTitleLargeAttributedString:(nullable NSString *)string {
return [MFStyler styleGetRegularTitleLargeAttributedString:string genericScaling:YES];
}
+ (nonnull NSAttributedString *)styleGetRegularTitleLargeAttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling {
return [MFStyler styleGetAttributedString:string font:[MFStyler fontRegularTitleLarge:genericScaling] color:[UIColor blackColor]];
}
+ (nonnull NSAttributedString *)styleGetBoldTitleMediumAttributedString:(nullable NSString *)string {
return [MFStyler styleGetBoldTitleMediumAttributedString:string genericScaling:YES];
}
+ (nonnull NSAttributedString *)styleGetBoldTitleMediumAttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling {
return [MFStyler styleGetAttributedString:string font:[MFStyler fontBoldTitleMedium:genericScaling] color:[UIColor blackColor]];
}
+ (nonnull NSAttributedString *)styleGetRegularTitleMediumAttributedString:(nullable NSString *)string {
return [MFStyler styleGetRegularTitleMediumAttributedString:string genericScaling:YES];
}
+ (nonnull NSAttributedString *)styleGetRegularTitleMediumAttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling {
return [MFStyler styleGetAttributedString:string font:[MFStyler fontRegularTitleMedium:genericScaling] color:[UIColor blackColor]];
}
+ (nonnull NSAttributedString *)styleGetBoldBodyLargeAttributedString:(nullable NSString *)string {
return [MFStyler styleGetBoldBodyLargeAttributedString:string genericScaling:YES];
}
+ (nonnull NSAttributedString *)styleGetBoldBodyLargeAttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling {
return [MFStyler styleGetAttributedString:string font:[MFStyler fontBoldBodyLarge:genericScaling] color:[UIColor blackColor]];
}
+ (nonnull NSAttributedString *)styleGetRegularBodyLargeAttributedString:(nullable NSString *)string {
return [MFStyler styleGetRegularBodyLargeAttributedString:string genericScaling:YES];
}
+ (nonnull NSAttributedString *)styleGetRegularBodyLargeAttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling {
return [MFStyler styleGetAttributedString:string font:[MFStyler fontRegularBodyLarge:genericScaling] color:[UIColor blackColor]];
}
+ (nonnull NSAttributedString *)styleGetBoldBodySmallAttributedString:(nullable NSString *)string {
return [MFStyler styleGetBoldBodySmallAttributedString:string genericScaling:YES];
}
+ (nonnull NSAttributedString *)styleGetBoldBodySmallAttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling {
return [MFStyler styleGetAttributedString:string font:[MFStyler fontBoldBodySmall:genericScaling] color:[UIColor blackColor]];
}
+ (nonnull NSAttributedString *)styleGetRegularBodySmallAttributedString:(nullable NSString *)string {
return [MFStyler styleGetRegularBodySmallAttributedString:string genericScaling:YES];
}
+ (nonnull NSAttributedString *)styleGetRegularBodySmallAttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling {
return [MFStyler styleGetAttributedString:string font:[MFStyler fontRegularBodySmall:genericScaling] color:[UIColor blackColor]];
}
+ (nonnull NSAttributedString *)styleGetBoldMicroAttributedString:(nullable NSString *)string {
return [MFStyler styleGetBoldMicroAttributedString:string genericScaling:YES];
}
+ (nonnull NSAttributedString *)styleGetBoldMicroAttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling {
return [MFStyler styleGetAttributedString:string font:[MFStyler fontBoldMicro:genericScaling] color:[UIColor blackColor]];
}
+ (nonnull NSAttributedString *)styleGetRegularMicroAttributedString:(nullable NSString *)string {
return [MFStyler styleGetRegularBodySmallAttributedString:string genericScaling:YES];
}
+ (nonnull NSAttributedString *)styleGetRegularMicroAttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling {
return [MFStyler styleGetAttributedString:string font:[MFStyler fontRegularMicro:genericScaling] color:[UIColor blackColor]];
}
//2.0 font get attributedString
+ (nonnull NSAttributedString *)styleGetH1AttributedString:(nullable NSString *)string {
return [MFStyler styleGetH1AttributedString:string genericScaling:YES];
}

View File

@ -12,8 +12,17 @@
@interface MFFonts : NSObject
///return mfFontTXBold when size smaller than 15, otherwise, return mfFontDSBold
+ (nonnull UIFont *)mfFont75Bd:(CGFloat)size;
///return mfFontTXRegular when size smaller than 15, otherwise, return mfFontDSRegular
+ (nonnull UIFont *)mfFont55Rg:(CGFloat)size;
//mva 3.0 font, should use mfFont75Bd/55Rg in most case.
+ (nonnull UIFont *)mfFontDSBold:(CGFloat)size;
+ (nonnull UIFont *)mfFontDSRegular:(CGFloat)size;
+ (nonnull UIFont *)mfFontTXBold:(CGFloat)size;
+ (nonnull UIFont *)mfFontTXRegular:(CGFloat)size;
+ (nullable UIFont *)mfFontOcratxt:(CGFloat)size;
+ (nonnull UIFont *)mfFontWithName:(nonnull NSString *)name size:(CGFloat)size;

View File

@ -47,13 +47,30 @@ static NSString * const TXRegular = @"VerizonNHGeTX-Regular";
CFRelease(provider);
}
+ (nonnull UIFont *)mfFontDSBold:(CGFloat)size {
return [UIFont fontWithName:DSBold size:size];
}
+ (nonnull UIFont *)mfFontDSRegular:(CGFloat)size {
return [UIFont fontWithName:DSRegular size:size];
}
+ (nonnull UIFont *)mfFontTXBold:(CGFloat)size {
return [UIFont fontWithName:TXBold size:size];
}
+ (nonnull UIFont *)mfFontTXRegular:(CGFloat)size {
return [UIFont fontWithName:TXRegular size:size];
}
+ (UIFont *)mfFont75Bd:(CGFloat)size {
[self loadMVMFonts];
UIFont *font;
if (size >= 15) {
font = [UIFont fontWithName:DSBold size:size];
font = [self mfFontDSBold:size];
} else {
font = [UIFont fontWithName:TXBold size:size];
font = [self mfFontTXBold:size];
}
return font ?: [UIFont boldSystemFontOfSize:size];
}
@ -62,9 +79,9 @@ static NSString * const TXRegular = @"VerizonNHGeTX-Regular";
[self loadMVMFonts];
UIFont *font;
if (size >= 15) {
font = [UIFont fontWithName:DSRegular size:size];
font = [self mfFontDSRegular:size];
} else {
font = [UIFont fontWithName:TXRegular size:size];
font = [self mfFontTXRegular:size];
}
return font ?: [UIFont systemFontOfSize:size];
}