Rotate UIView with constraints

I’m trying to achieve this:

I have tried rotating it with transform such as:

greenView.transform = CGAffineTransform(rotationAngle: -(.pi/2))

But can’t achieve the desire effect. Can anyone please, let me know on how to properly do this? Thanks

Hi @efthemiosprime, have you tried this?

let degrees : Double = -90; 
greenView.transform = CGAffineTransform(rotationAngle: CGFloat(degrees * .pi/180))


1 Like

Hi @efthemiosprime,
one thing to note is that most transforms are additive, i.e. start from the last transformation as the start. You can reset it by using the TransformIdentity


1 Like

This topic was automatically closed after 166 days. New replies are no longer allowed.