diff options
Diffstat (limited to 'platform/darwin/src/MGLAttributedExpression.h')
-rw-r--r-- | platform/darwin/src/MGLAttributedExpression.h | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/platform/darwin/src/MGLAttributedExpression.h b/platform/darwin/src/MGLAttributedExpression.h index 32f1a96dae..ea298c7a44 100644 --- a/platform/darwin/src/MGLAttributedExpression.h +++ b/platform/darwin/src/MGLAttributedExpression.h @@ -2,10 +2,16 @@ NS_ASSUME_NONNULL_BEGIN -typedef NSString * MGLAttributedExpressionKey NS_EXTENSIBLE_STRING_ENUM; +/** Options for `MGLAttributedExpression.attributes`. */ +typedef NSString * MGLAttributedExpressionKey NS_TYPED_ENUM; +/** The font name string array expression used to format the text. */ FOUNDATION_EXTERN MGL_EXPORT MGLAttributedExpressionKey const MGLFontNamesAttribute; -FOUNDATION_EXTERN MGL_EXPORT MGLAttributedExpressionKey const MGLFontSizeAttribute; + +/** The font scale number expression relative to `MGLSymbolStyleLayer.textFontSize` used to format the text. */ +FOUNDATION_EXTERN MGL_EXPORT MGLAttributedExpressionKey const MGLFontScaleAttribute; + +/** The font color expression used to format the text. */ FOUNDATION_EXTERN MGL_EXPORT MGLAttributedExpressionKey const MGLFontColorAttribute; /** @@ -16,10 +22,10 @@ FOUNDATION_EXTERN MGL_EXPORT MGLAttributedExpressionKey const MGLFontColorAttrib ```swift let redColor = UIColor.red let expression = NSExpression(forConstantValue: "Foo") - let attributes: Dictionary<MGLAttributedExpressionKey, Any> = [.fontNamesAttribute : ["DIN Offc Pro Italic", - "Arial Unicode MS Regular"], - .fontSizeAttribute: 1.2, - .fontColorAttribute: redColor] + let attributes: [MGLAttributedExpressionKey: NSExpression] = [.fontNamesAttribute : NSExpression(forConstantValue: ["DIN Offc Pro Italic", + "Arial Unicode MS Regular"]), + .fontScaleAttribute: NSExpression(forConstantValue: 1.2), + .fontColorAttribute: NSExpression(forConstantValue: redColor)] let attributedExpression = MGLAttributedExpression(expression, attributes:attributes) ``` @@ -37,22 +43,22 @@ MGL_EXPORT The formatting attributes dictionary. Key | Value Type --- | --- - `MGLFontNamesAttribute` | `NSArray<NSString *>*` - `MGLFontSizeAttribute` | `NSNumber` - `MGLFontColorAttribute` | `UIColor` + `MGLFontNamesAttribute` | An `NSExpression` evaluating to an `NSString` array. + `MGLFontScaleAttribute` | An `NSExpression` evaluating to an `NSNumber` value. + `MGLFontColorAttribute` | An `NSExpression` evaluating to an `UIColor`. */ -@property (strong, nonatomic, readonly) NSDictionary<MGLAttributedExpressionKey, id> *attributes; +@property (strong, nonatomic, readonly) NSDictionary<MGLAttributedExpressionKey, NSExpression *> *attributes; #else /** The formatting attributes dictionary. Key | Value Type --- | --- - `MGLFontNamesAttribute` | `NSArray<NSString *>*` - `MGLFontSizeAttribute` | `NSNumber` - `MGLFontColorAttribute` | `NSColor` + `MGLFontNamesAttribute` | An `NSExpression` evaluating to an `NSString` array. + `MGLFontScaleAttribute` | An `NSExpression` evaluating to an `NSNumber` value. + `MGLFontColorAttribute` | An `NSExpression` evaluating to an `NSColor` on macos. */ -@property (strong, nonatomic, readonly) NSDictionary<MGLAttributedExpressionKey, id> *attributes; +@property (strong, nonatomic, readonly) NSDictionary<MGLAttributedExpressionKey, NSExpression *> *attributes; #endif @@ -64,17 +70,17 @@ MGL_EXPORT /** Returns an `MGLAttributedExpression` object initialized with an expression and text format attributes. */ -- (instancetype)initWithExpression:(NSExpression *)expression attributes:(nonnull NSDictionary <MGLAttributedExpressionKey, id> *)attrs; +- (instancetype)initWithExpression:(NSExpression *)expression attributes:(nonnull NSDictionary <MGLAttributedExpressionKey, NSExpression *> *)attrs; /** Creates an `MGLAttributedExpression` object initialized with an expression and the format attributes for font names and font size. */ -+ (instancetype)attributedExpression:(NSExpression *)expression fontNames:(nullable NSArray<NSString*> *)fontNames fontSize:(nullable NSNumber *)fontSize; ++ (instancetype)attributedExpression:(NSExpression *)expression fontNames:(nullable NSArray<NSString*> *)fontNames fontScale:(nullable NSNumber *)fontScale; /** Creates an `MGLAttributedExpression` object initialized with an expression and the format attributes dictionary. */ -+ (instancetype)attributedExpression:(NSExpression *)expression attributes:(nonnull NSDictionary <MGLAttributedExpressionKey, id> *)attrs; ++ (instancetype)attributedExpression:(NSExpression *)expression attributes:(nonnull NSDictionary <MGLAttributedExpressionKey, NSExpression *> *)attrs; @end |