In CGAffineTransform documentation https://developer.apple.com/documentation/coregraphics/cgaffinetransform the equations that transform point (x, y) to point (x’,y’) are as follows: x'=ax+cy+t_x, y'=bx+dy+t_y. Consider the case where we have scaling on a view. Then the equations become x'=ax, y'=dy. This means that according to the equations the point that remains at the same position after the scaling is (0,0). However, the point that remains at the same position is the center of the view. This can be seen in practice, as well as here: https://developer.apple.com/documentation/quartzcore/calayer/1410817-anchorpoint.
My question is: Are the equations provided in CGAffineTransform documentation, incorrect indeed?
This means that according to the equations the point that remains at the same position after the scaling is (0,0).
Exactly. But (0,0) is the anchor point, not the "view bounds origin" which I believe you're expecting.
However, the point that remains at the same position is the center of the view.
Exactly. Because that's where the anchor point is.
You even link to the documentation that explains this. Transforms are applied to a coordinate space based on the anchor point. The default anchor point is in the center of the view. This is independent of the coordinate space of bounds
.
CALayer works in a coordinate space from (0,0) to (1,1), with (0.5, 0.5) in its center. The default anchor point is the center, but can be moved.
The docs are very clear about that. They're not misleading or incorrect:
This property [transform] is set to the identity transform by default. Any transformations you apply to the layer occur relative to the layer’s anchor point.
To make the transform "relative to the layer's anchor point," scaling and translation may be applied. That's fine; that's how affine transforms work. They can be freely combined to moved between coordinate spaces. If you want the coordinate space to be anchored a the upper-left corner, move the anchor point.