Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 955
Chris Pillen Avatar asked Mar 03 '12 15:03

Chris Pillen


2 Answers

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.

like image 120
a_nub Avatar answered Oct 22 '22 21:10

a_nub


For me the solution was to set the imageView content mode to .center

imageView.contentMode = .center

like image 39
Ghadeer Alkubaish Avatar answered Oct 22 '22 20:10

Ghadeer Alkubaish