Merge branch 'feature/html_label' into 'develop'
html string See merge request BPHV_MIPS/mvm_core_ui!15
This commit is contained in:
commit
1d6293a0d5
@ -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;
|
||||
|
||||
@ -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];
|
||||
|
||||
Loading…
Reference in New Issue
Block a user