Search code examples
objective-ciosuiviewcgaffinetransform

UIView rotated by 45° disappears?


maybe I don't get. When I do

self.tweetPeak.transform = CGAffineTransformMakeRotation(RADIANS(45));

where RADIAN is

#define RADIANS(degrees) ((degrees * M_PI) / 180.0)

on a simple UIView Object it will disappear.

I guess it's just to thin to see. My impression is that the view is getting smaller in a range between 20 to 45 degrees.

What is it? I tried to set the view opaque. No effect.

chris


Solution

  • You need to stop adjusting the frame after the rotation, it causes undesired stretching to the transform matrix, I'm unsure to the formal reason why, but it has something to do with Apple using their own matrix system rather than traditional matrices to represent 2D/3D translations/rotations/scale. I was having the same problem the other day, to fix it, instead of rotating that view, I just made it a container with the actual view I wanted rotated inside, and rotated that.