MGLAttributedExpression
@interface MGLAttributedExpression : NSObject
An MGLAttributedExpression object associates text formatting attibutes (such as font size or
font names) to an NSExpression.
Example
let redColor = UIColor.red
let expression = NSExpression(forConstantValue: "Foo")
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)
-
The expression content of the receiver as
NSExpression.Declaration
Objective-C
@property (nonatomic, strong) NSExpression *_Nonnull expression;Swift
var expression: NSExpression { get set } -
The formatting attributes dictionary. Key | Value Type — | —
MGLFontNamesAttribute| AnNSExpressionevaluating to anNSStringarray.MGLFontScaleAttribute| AnNSExpressionevaluating to anNSNumbervalue.MGLFontColorAttribute| AnNSExpressionevaluating to anNSColoron macos.Declaration
Objective-C
@property (nonatomic, strong, readonly) NSDictionary<MGLAttributedExpressionKey, NSExpression *> *_Nonnull attributes;Swift
var attributes: [MGLAttributedExpressionKey : NSExpression] { get } -
Returns an
MGLAttributedExpressionobject initialized with an expression and no attribute information.Declaration
Objective-C
- (nonnull instancetype)initWithExpression:(nonnull NSExpression *)expression;Swift
init(expression: NSExpression) -
Returns an
MGLAttributedExpressionobject initialized with an expression and text format attributes.Declaration
Objective-C
- (nonnull instancetype) initWithExpression:(nonnull NSExpression *)expression attributes:(nonnull NSDictionary<MGLAttributedExpressionKey, NSExpression *> *)attrs;Swift
init(expression: NSExpression, attributes attrs: [MGLAttributedExpressionKey : NSExpression] = [:]) -
Creates an
MGLAttributedExpressionobject initialized with an expression and the format attributes for font names and font size.Declaration
Objective-C
+ (nonnull instancetype)attributedExpression:(nonnull NSExpression *)expression fontNames: (nullable NSArray<NSString *> *)fontNames fontScale:(nullable NSNumber *)fontScale;Swift
convenience init(_ expression: NSExpression, fontNames: [String]?, fontScale: NSNumber?) -
Creates an
MGLAttributedExpressionobject initialized with an expression and the format attributes dictionary.Declaration
Objective-C
+ (nonnull instancetype) attributedExpression:(nonnull NSExpression *)expression attributes:(nonnull NSDictionary<MGLAttributedExpressionKey, NSExpression *> *)attrs;Swift
convenience init(_ expression: NSExpression, attributes attrs: [MGLAttributedExpressionKey : NSExpression] = [:])
Install in Dash
MGLAttributedExpression Class Reference