Annotation style view controller

The AnnotStyleViewController class shows annotation style properties in a half-modal bottom sheet. With this style editor, users can edit annotation styles easily with style presets as well as choosing their own colors through the color picker.

The annotation style editor is part of the Tools library, so make sure you have added the Tools library to your project.

Showing/hiding the style view controller

The annotation style state for the given annotation is managed by an AnnotStyle instance. To create and display a new annotation style view controller from another view controller, first create and supply an AnnotStyle instance to the AnnotStyleViewController initializer:

AnnotStyle can also be initialized with an PTAnnotType, in wich case the AnnotStyle will operate on the default style properties for that annotation type. (The default style properties are the ones that are used when a new annotation of that type is created.)

To hide the annotation style view controller programmatically, call dismissViewControllerAnimated:completion on either the presenting view controller or the annotation view controller itself.

Saving annotation style changes

The annotation view controller does not commit the annotation style changes back to the annotation unless explicitly told to do so. To commit the annotation style changes, implement the annotStyleViewController:didCommitStyle: and/or annotStyleViewController:didChangeStyle: methods of the AnnotStyleViewControllerDelegate protocol:

The annotStyleViewController:didCommitStyle: method is called when the annotation style view controller is dismissed either by the user pressing the 'Done' button or de-selecting the current annotation. The optional annotStyleViewController:didChangeStyle: method is called immediately after any annotation style property is changed by the user. For slider-controlled properties (thickness, opacity, etc.), an event notifying of the change is triggered when the user releases the slider control.

The saveAnnotStyleChanges: helper method used above can be defined as follows:

The call to setCurrentValuesAsDefaults in the code above is not necessary if the saveValuesAsDefaults property (enabled by default) is set, as in this case saveChanges will automatically save the style as the new default style.

The sequence of document locking and annotation updates shown here is used throughout the Tools framework. For more information on document locking please see the dedicated guide.