CAShapeLayer: strokeColor property
The strokeColor property is the color of the line.
Value
A color string, or null.
- Readable and writable.
- Defaults to
null, no stroke. Setting onlylineWidthwithout a color shows no line. - When writing, accepts color strings as well as
UIColorobjects. - A color that varies with light and dark mode is resolved to a fixed color when written and does not change when the mode switches later; see Colors on layers.
Invalid values
Writing an invalid color does not throw. The console logs a warning and the property keeps its previous value:
[Nacre] strokeColor: "#GGG" is not a valid color, ignoredExamples
js
const shape = new CAShapeLayer();
shape.path = UIBezierPath.bezierPathWithRect(new CGRect(20, 20, 260, 120));
shape.fillColor = null;
shape.strokeColor = 'systemBlue';Effect: a rectangle with a blue outline 1 pt wide.
Corresponding iOS API
CAShapeLayer.strokeColor.