Merge branch 'feature/html_label' into 'develop'

html string

See merge request BPHV_MIPS/mvm_core_ui!15
This commit is contained in:
Suresh, Kamlesh 2019-03-27 11:30:34 -04:00
commit 1d6293a0d5
2 changed files with 15 additions and 0 deletions

View File

@ -56,6 +56,8 @@
+ (nonnull MFLabel *)commonLabelTopAlert:(BOOL)scale;
// Setters
+ (void)setLabel:(nullable UILabel *)label withHTML:(nullable NSString *)html;
+ (void)setUILabel:(nullable UILabel *)label withJSON:(nullable NSDictionary *)json delegate:(nullable NSObject *)delegate additionalData:(nullable NSDictionary *)additionalData;
- (void)styleB2:(BOOL)scale;
- (void)styleBodyWithSize:(CGFloat)size scale:(BOOL)scale;
- (void)styleBodyBold:(BOOL)scale;

View File

@ -13,6 +13,7 @@
#import "UIColor+MFConvenience.h"
#import "MFFonts.h"
#import "MVMCoreUISplitViewController.h"
#import "MVMCoreUILoggingHandler.h"
@import MVMCore.MVMCoreGetterUtility;
@import MVMCore.NSDictionary_MFConvenience;
@import MVMCore.MVMCoreJSONConstants;
@ -237,9 +238,21 @@
#pragma mark - Setters
+ (void)setLabel:(nullable UILabel *)label withHTML:(nullable NSString *)html {
NSData *data = [html dataUsingEncoding:kCFStringEncodingUTF8];
if (data) {
NSError *error = nil;
label.attributedText = [[NSAttributedString alloc] initWithData:data options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType} documentAttributes:nil error:&error];
if (error) {
[[MVMCoreUILoggingHandler sharedLoggingHandler] addErrorToLog:[MVMCoreErrorObject createErrorObjectForNSError:error location:@"LabelHTMLParse"]];
}
}
}
+ (void)setUILabel:(nullable UILabel *)label withJSON:(nullable NSDictionary *)json delegate:(nullable NSObject *)delegate additionalData:(nullable NSDictionary *)additionalData {
if (label) {
label.text = [json string:KeyText];
[self setLabel:label withHTML:[json string:@"html"]];
NSString *textColor = [json string:KeyTextColor];
if (textColor) {
label.textColor = [UIColor mfGetColorForHex:textColor];