From 174c8fa7e4927ebf28a3d0e07c995d3e3d69de76 Mon Sep 17 00:00:00 2001 From: Fabian Guerra Soto Date: Tue, 19 Mar 2019 14:53:35 -0700 Subject: [ios, macos] Add text-color support to format expressions. (#14146) Added the possibility of overriding paint properties inside the format expression. Added an example of how to create an MGLAttributedExpression object and documented the attributes keys and value types. Fixed a bug that ignored the font names. --- platform/darwin/src/MGLAttributedExpression.m | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'platform/darwin/src/MGLAttributedExpression.m') diff --git a/platform/darwin/src/MGLAttributedExpression.m b/platform/darwin/src/MGLAttributedExpression.m index 715f74e42f..000701f7cf 100644 --- a/platform/darwin/src/MGLAttributedExpression.m +++ b/platform/darwin/src/MGLAttributedExpression.m @@ -3,11 +3,12 @@ const MGLAttributedExpressionKey MGLFontNamesAttribute = @"text-font"; const MGLAttributedExpressionKey MGLFontSizeAttribute = @"font-scale"; +const MGLAttributedExpressionKey MGLFontColorAttribute = @"text-color"; @implementation MGLAttributedExpression - (instancetype)initWithExpression:(NSExpression *)expression { - self = [self initWithExpression:expression attributes:nil]; + self = [self initWithExpression:expression attributes:@{}]; return self; } @@ -28,7 +29,15 @@ const MGLAttributedExpressionKey MGLFontSizeAttribute = @"font-scale"; return attributedExpression; } -- (instancetype)initWithExpression:(NSExpression *)expression attributes:(NSDictionary *)attrs { ++ (instancetype)attributedExpression:(NSExpression *)expression attributes:(nonnull NSDictionary *)attrs { + MGLAttributedExpression *attributedExpression; + + attributedExpression = [[self alloc] initWithExpression:expression attributes:attrs]; + + return attributedExpression; +} + +- (instancetype)initWithExpression:(NSExpression *)expression attributes:(nonnull NSDictionary *)attrs { if (self = [super init]) { MGLLogInfo(@"Starting %@ initialization.", NSStringFromClass([self class])); -- cgit v1.2.1