Some test text!

Loading...
Guides
Custom style presets

Customize annotation style presets on iOS

Overview

Annotation tools come with a set of four presets, accessible from the presets section:

style-picker

Annotation tools can also be invoked via a long-press.

These presets are "sticky" in that changes made by the user to each preset will persist between runs of your app.

This guide explains how to customize the initial values of the presets.

Customizing Presets

Presets are customized using a custom plist (property list) that must be called PTAnnotationStyleDefaults.plist file included in your app's bundle. This can be done by including the file in your Xcode project and ensuring that it is copied into the app bundle as shown:

include-plist-file

The plist contains an array of dictionaries. Each dictionary has two entries, one with the key types and the other with the key presets.

The value of the types entry is an array of strings, where each string value is the name of the annotation type for which the associated presets apply.

The value of the presets entry is an array of exactly four dictionaries, where each dictionary represents one preset. The dictionaries contain key/value pairs, where the key is the annotation property, and the value is its initial value.

This is an example .plist file, shown in Xcode's plist editor, and written as xml. A list of all possible keys follows the example. You can also download the example plist file.

style-picker

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
	<dict>
		<key>types</key>
		<array>
			<string>Ink</string>
		</array>
		<key>presets</key>
		<array>
			<dict>
				<key>thickness</key>
				<integer>2</integer>
				<key>color</key>
				<string>#00ff00</string>
			</dict>
			<dict>
				<key>thickness</key>
				<integer>4</integer>
				<key>color</key>
				<string>#00ff00</string>
			</dict>
			<dict>
				<key>thickness</key>
				<integer>8</integer>
				<key>color</key>
				<string>#ff0000</string>
			</dict>
			<dict>
				<key>thickness</key>
				<integer>16</integer>
				<key>color</key>
				<string>#ff0000</string>
			</dict>
		</array>
	</dict>
	<dict>
		<key>types</key>
		<array>
			<string>Highlight</string>
		</array>
		<key>presets</key>
		<array>
			<dict>
				<key>color</key>
				<string>#123456</string>
				<key>opacity</key>
				<real>0.3</real>
			</dict>
			<dict>
				<key>color</key>
				<string>#00ff00</string>
			</dict>
			<dict>
				<key>color</key>
				<string>#00ffff</string>
			</dict>
			<dict>
				<key>color</key>
				<string>#ff00ff</string>
			</dict>
		</array>
	</dict>
	<dict>
		<key>types</key>
		<array>
			<string>Underline</string>
			<string>Squiggly</string>
			<string>StrikeOut</string>
		</array>
		<key>presets</key>
		<array>
			<dict>
				<key>color</key>
				<string>#111111</string>
			</dict>
			<dict>
				<key>color</key>
				<string>#00cc63</string>
			</dict>
			<dict>
				<key>color</key>
				<string>#4e7de9</string>
			</dict>
			<dict>
				<key>color</key>
				<string>#000000</string>
			</dict>
		</array>
	</dict>
</array>
</plist>
presets keyvalueproperty
colorhex-formatted RRGGBB string, e.g. #ff0000The color or stroke color of the annotation.
fillColorhex-formatted RRGGBB string, e.g. #00ff00The fill color of the annotation.
textColorhex-formatted RRGGBB string, e.g. #0000ffThe color of the text of a PTFreeText annotation.
textSizenumber, e.g. 16The font size, in pts, of a PTFreeText annotation.
thicknessnumber, e.g. 2The thickness, in pixels, of an annotation's stroke.
opacitynumber between 0 and 1, e.g. 0.5The opacity of an annotation.
types array (case sensitive)
Text
Link
FreeText
Line
Square
Circle
Polygon
Polyline
Highlight
Underline
Squiggly
StrikeOut
Stamp
Caret
Ink
Popup
FileAttachment
Sound
Movie
Widget
Screen
PrinterMark
TrapNet
Watermark
ThreeDimensional
Redact
Projection
RichMedia
Arrow
Signature
Cloudy
Ruler
Perimeter
Area
ImageStamp
PencilDrawing
FreehandHighlight
Callout

Get the answers you need: Support