The dash pattern applied to the shape’s path when stroked.
- iOS 3.0+
- macOS 10.6+
- tvOS 9.0+
- Core Animation
The dash pattern is specified as an array of
NSNumber objects that specify the lengths of the painted segments and unpainted segments, respectively, of the dash pattern.
For example, passing an array with the values
[2,3] sets a dash pattern that alternates between a 2-user-space-unit-long painted segment and a 3-user-space-unit-long unpainted segment. Passing the values
[10,5,5,5] sets the pattern to a 10-unit painted segment, a 5-unit unpainted segment, a 5-unit painted segment, and a 5-unit unpainted segment.
nil, a solid line.
Listing 1 shows how how you can create three shape layers using the dash patterns described above. Each shape layer contains a simple path that describes a horizontal line.
Figure 1 shows three shape layers created with the code above. The top solid line has a
line, the middle has
[2,3] and the bottom has