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)
expression
The expression content of the receiver as NSExpression
.
Declaration
Objective-C
@property (nonatomic, strong, readwrite) NSExpression *_Nonnull expression;
Swift
var expression: NSExpression { get set }
attributes
The formatting attributes dictionary. Key | Value Type — | — MGLFontNamesAttribute |
An NSExpression evaluating to an NSString array. MGLFontScaleAttribute |
An NSExpression evaluating to an NSNumber value. MGLFontColorAttribute |
An NSExpression evaluating to an UIColor . |
Declaration
Objective-C
@property (nonatomic, strong, readonly)
NSDictionary<MGLAttributedExpressionKey, NSExpression *>
*_Nonnull attributes;
Swift
var attributes: [MGLAttributedExpressionKey : NSExpression] { get }
-initWithExpression:
Returns an MGLAttributedExpression
object initialized with an expression and no attribute information.
Declaration
Objective-C
- (nonnull instancetype)initWithExpression:(nonnull NSExpression *)expression;
Swift
init(expression: NSExpression)
-initWithExpression:attributes:
Returns an MGLAttributedExpression
object 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] = [:])
+attributedExpression:fontNames:fontScale:
Creates an MGLAttributedExpression
object 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?)
+attributedExpression:attributes:
Creates an MGLAttributedExpression
object 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] = [:])
iOS SDK
Examples
SDK JS Reference
- MGLAnnotationImage
- MGLErrorCode
- MGLNetworkConfiguration
- MGLCircleStyleLayer
- MGLUserTrackingMode
- MGLTransition
- MGLCoordinateFormatter
- MGLImageSource
- MGLOrnamentPosition
- MGLAnnotation
- Other Type Definitions
- MGLAnnotationViewDragState
- NSValue(MGLCircleStyleLayerAdditions)
- MGLPolyline
- MGLCoordinateQuad
- MGLDEMEncoding
- Styling the Map
- MGLAttributionInfoStyle
- MGLTextTranslationAnchor
- MGLSymbolPlacement
- MGLOfflineStorage
- MGLHillshadeStyleLayer
- Other Functions
- MGLCompassButton
- MGLAttributionInfo
- MGLHeatmapStyleLayer
- Other Categories
- MGLSphericalPosition
- MGLCirclePitchAlignment
- User Interaction
- Location Updates
- MGLSphericalPosition
- Offline Maps
- MGLSymbolZOrder
- MGLIconRotationAlignment
- MGLLightAnchor
- MGLLocationManagerDelegate
- MGLAttributedExpression
- MGLLight
- MGLStyleLayer
- NSExpression(MGLAdditions)
- MGLAccountManager
- MGLShapeOfflineRegion
- Geometry
- MGLHillshadeIlluminationAnchor
- Info.plist Keys
- MGLBackgroundStyleLayer
- MGLSource
- MGLSymbolStyleLayer
- MGLResourceKind
- MGLCoordinateSpan
- MGLOrnamentVisibility
- NSValue(MGLFillExtrusionStyleLayerAdditions)
- NSValue(MGLHillshadeStyleLayerAdditions)
- MGLOfflineStorageDelegate
- MGLCluster
- Appendices
- MGLUserLocationAnnotationViewStyle
- NSValue(MGLLineStyleLayerAdditions)
- MGLStyle
- MGLMapSnapshotterDelegate
- MGLTextWritingMode
- MGLRasterResamplingMode
- MGLUserLocation
- MGLOfflinePackProgress
- MGLFillExtrusionTranslationAnchor
- MGLForegroundStyleLayer
- MGLLoggingConfiguration
- MGLTilePyramidOfflineRegion
- MGLRasterTileSource
- MGLAnnotationView
- Working with GeoJSON Data
- MGLVectorStyleLayer
- MGLMapSnapshotOptions
- MGLMapViewDelegate
- MGLMapDebugMaskOptions
- MGLMapSnapshotOverlay
- MGLIconTranslationAnchor
- Other Enumerations
- Other Protocols
- MGLTextRotationAlignment
- MGLUserLocationAnnotationView
- MGLTextPitchAlignment
- MGLCalloutViewDelegate
- Annotations
- MGLLineTranslationAnchor
- MGLShapeSource
- NSValue(MGLSymbolStyleLayerAdditions)
- MGLOfflinePackState
- MGLTextJustification
- Other Classes
- MGLMapSnapshotter
- MGLIconPitchAlignment
- MGLComputedShapeSource
- MGLRasterStyleLayer
- MGLCoordinateQuad
- MGLFeature
- MGLComputedShapeSourceDataSource
- MGLOfflineRegion
- MGLLineCap
- MGLLoggingLevel
- MGLFillExtrusionStyleLayer
- Style Content
- NSValue(MGLFillStyleLayerAdditions)
- NSValue(MGLRasterStyleLayerAdditions)
- MGLLocationManager
- MGLMapCamera
- MGLIconTextFit
- MGLLineStyleLayer
- MGLPointCollection
- MGLMultiPolygon
- MGLCircleTranslationAnchor
- Other Structures
- MGLFillStyleLayer
- MGLShapeCollection
- Primitive Shapes
- MGLTransition
- Information for Style Authors
- MGLLineJoin
- MGLPointAnnotation
- MGLTileSource
- MGLVectorTileSource
- MGLCoordinateBounds
- Gesture Recognizers
- NSValue(MGLAdditions)
- MGLCompassDirectionFormatter
- MGLIconAnchor
- Migrating to Expressions
- MGLPolygon
- MGLDistanceFormatter
- MGLFillTranslationAnchor
- MGLTextTransform
- MGLMultiPoint
- Customizing Fonts
- Maps
- MGLClockDirectionFormatter
- MGLCalloutView
- MGLTextAnchor
- MGLCircleScaleAlignment
- MGLCoordinateSpan
- MGLMapSnapshot
- MGLStylable
- MGLShape
- MGLOfflinePackProgress
- Style Primitives
- Predicates and expressions
- Formatters
- MGLMultiPolyline
- MGLTileCoordinateSystem
- MGLAnnotationVerticalAlignment
- MGLOverlay
- MGLCoordinateBounds
- Tile URL Templates
- MGLOfflinePack
- Style Layers
- MGLMapView
- Other Constants
On this page