Search code examples
iosswiftrotationorientationpi

how to get image orientation to rotate 270 degrees (swift3)


Right now this code will only rotate my image 90 degrees. I can not figure out how to rotate it 270 degrees.

        transform = transform.rotated(by: CGFloat(Double.pi))

Solution

  • Start with some basic math.

    360° = 2π. 180° = π. 90° = π/2. 270° = 3π/2.

    This means your posted code is rotating 180 degrees.

    Use Double.pi/2 for 90° and 3*Double.pi/2 for 270°.