Calling button.transform.rotated(by: CGFloat(Float.pi)) does not make any change to the button's transform property. Instead, it constructs a new copy of the property and rotates it. To rotate a button 180 degree, you can call the rotated() method on the existing transform property and assign the returned affine transformation matrix back to it as following:
button.transform = button.transform.rotated(by: CGFloat(Float.pi))
The rotated() method takes a floating-point number as a parameter which is a value of radian.
Radian
Radian is an International System unit used for measuring angles. The value of radian π or 3.14 is converted to an angle of 180 degree.
Affine Transformation
Affine transformation is used to transform an image by preserving points, straight lines, and planes. Examples of an affine transformation are translation, scaling, and rotation. It modifies its matrix to get a new coordinate of each point in an image for transformation.
No comments:
Post a Comment