MKOverlayPathView Class Reference
| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/MapKit.framework |
| Availability | Available in iOS 4.0 and later. |
| Companion guide | |
| Declared in | MKOverlayPathView.h |
Overview
The MKOverlayPathView class represents a generic overlay that draws its contents using a CGPathRef data type. You can use this class to implement simple path-based overlay views or subclass it to define additional drawing behaviors. The default drawing behavior of this class is to apply the object’s current fill attributes, fill the path, apply the current stroke attributes, and then stroke the path.
If you subclass, you should override the createPath method and use that method to build the appropriate path for the overlay. You can invalidate this path as needed and force the path to be recreated using whatever new data your subclass has obtained.
Tasks
Accessing the Drawing Attributes
-
fillColorproperty -
strokeColorproperty -
lineWidthproperty -
lineJoinproperty -
lineCapproperty -
miterLimitproperty -
lineDashPhaseproperty -
lineDashPatternproperty
Creating and Managing the Path
-
pathproperty -
– createPath -
– invalidatePath
Drawing the Path
Properties
fillColor
The fill color to use for the path.
Availability
- Available in iOS 4.0 and later.
Declared In
MKOverlayPathView.hlineCap
The line cap style to apply to the open ends of the path.
Discussion
The line cap style is applied to the start and end points of any open subpaths. This property does not affect closed subpaths. The default line cap style is kCGLineCapButt.
Availability
- Available in iOS 4.0 and later.
Declared In
MKOverlayPathView.hlineDashPattern
An array of numbers indicating the dash pattern for paths.
Discussion
The array contains one or more NSNumber objects that indicate the lengths (measured in points) of the line segments and gaps in the pattern. The values in the array alternate, starting with the first line segment length, followed by the first gap length, followed by the second line segment length, and so on.
This property is set to nil by default, which indicates no line dash pattern.
Availability
- Available in iOS 4.0 and later.
Declared In
MKOverlayPathView.hlineDashPhase
The
Availability
- Available in iOS 4.0 and later.
Declared In
MKOverlayPathView.hlineJoin
The line join style to apply to corners of the path.
Discussion
The default line join style is kCGLineJoinMiter.
Availability
- Available in iOS 4.0 and later.
Declared In
MKOverlayPathView.hlineWidth
The stroke width to use for the path.
Discussion
The default value of this property is 0.
Availability
- Available in iOS 4.0 and later.
Declared In
MKOverlayPathView.hmiterLimit
The limiting value that helps avoid spikes at junctions between connected line segments.
Discussion
The miter limit helps you avoid spikes in paths that use the kCGLineJoinMiter join style. If the ratio of the miter length—that is, the diagonal length of the miter join—to the line thickness exceeds the miter limit, the joint is converted to a bevel join. The default miter limit is 10, which results in the conversion of miters whose angle at the joint is less than 11 degrees.
Availability
- Available in iOS 4.0 and later.
Declared In
MKOverlayPathView.hpath
The current path to use when drawing the overlay.
Discussion
Getting the value of this property causes the path to be created (using the createPath method) if it does not already exist. You can also assign a path object to this property explicitly.
When assigning a new path object to this property, the receiver retains the path you specify.
Availability
- Available in iOS 4.0 and later.
See Also
Declared In
MKOverlayPathView.hstrokeColor
The stroke color to use for the path.
Availability
- Available in iOS 4.0 and later.
Declared In
MKOverlayPathView.hInstance Methods
applyFillPropertiesToContext:atZoomScale:
Applies the receiver’s current fill-related drawing properties to the specified graphics context
Parameters
- context
The graphics context used to draw the view’s contents.
- zoomScale
The current zoom scale used for drawing.
Discussion
This is a convenience method for applying all of the drawing properties used when filling a path. This method applies the current fill color to the specified graphics context.
Availability
- Available in iOS 4.0 and later.
See Also
Declared In
MKOverlayPathView.happlyStrokePropertiesToContext:atZoomScale:
Applies the receiver’s current stroke-related drawing properties to the specified graphics context.
Parameters
- context
The graphics context used to draw the view’s contents.
- zoomScale
The current zoom scale used for drawing.
Discussion
This is a convenience method for applying all of the drawing properties used when stroking a path. This method applies the stroke color, line width, line join, line cap, miter limit, line dash phase, and line dash attributes to the specified graphics context. This method applies the scale factor in the zoomScale parameter to the line width and line dash pattern automatically so that lines scale appropriately.
This method does not save the current graphics state before applying the new attributes. You must save it yourself and restore it later when you are done drawing.
Availability
- Available in iOS 4.0 and later.
See Also
Declared In
MKOverlayPathView.hcreatePath
Creates the path for the overlay.
Discussion
The default implementation of this method does nothing. Subclasses should override it and use it to create the CGPathRef data type to be used for drawing. After creating the path, your implementation should then assign it to the path property.
Availability
- Available in iOS 4.0 and later.
Declared In
MKOverlayPathView.hfillPath:inContext:
Fills the area enclosed by the specified path.
Parameters
- path
The path to fill.
- context
The graphics context in which to draw the path.
Discussion
You must set the current fill color before calling this method. Typically you do this by calling the applyFillPropertiesToContext:atZoomScale: method prior to drawing. If the fillColor property is currently nil, this method does nothing.
Availability
- Available in iOS 4.0 and later.
Declared In
MKOverlayPathView.hinvalidatePath
Releases the path associated with the receiver.
Discussion
You can call this method at any time where a change in the path information would require you to recreate the path. This method sets the path property to nil, which causes the cached path to be released.
Availability
- Available in iOS 4.0 and later.
Declared In
MKOverlayPathView.hstrokePath:inContext:
Draws a line along the specified path.
Parameters
- path
The path to draw.
- context
The graphics context in which to draw the path.
Discussion
You must set the current stroke color before calling this method. Typically you do this by calling the applyStrokePropertiesToContext:atZoomScale: method prior to drawing. If the strokeColor property is currently nil, this method does nothing.
Availability
- Available in iOS 4.0 and later.
Declared In
MKOverlayPathView.h© 2010 Apple Inc. All Rights Reserved. (Last updated: 2010-05-11)