Instance Property

attributedInstructionVariants

An array of attributed strings representing the instruction variants for the maneuver.

Declaration

var attributedInstructionVariants: [NSAttributedString] { get set }

Discussion

Localize each variant for display to the user, and make sure the array has at least one variant. The system displays the first variant that fits into the available screen space, so arrange the variants from most to least preferred display order.

The attributed strings contained in the attributedInstructionVariants array should have only one attribute, NSTextAttachment. The system removes all other attributes.

Using a text attachment attribute, you can add an image to a maneuver instruction as shown in Listing 1. The maximum image size is 64 x 16 points at @3X scale (192 x 48 pixel).

Listing 1

An example of attaching an image to an attributed string

let instructions = NSMutableAttributedString(string: "Some text.")

// Attach an image.
let attachment = NSTextAttachment()
attachment.image =  imageLiteral(resourceName: "red-rectangle")
let imageString = NSAttributedString(attachment: attachment)

instructions.append(imageString)
instructions.append(NSAttributedString(string: "More text."))

See Also

Providing Maneuver Information

var instructionVariants: [String]

An array of instruction variants for the maneuver.

var initialTravelEstimates: CPTravelEstimates?

The distance between the end of the previous maneuver and the beginning of this one.