Chris Pillen
Chris Pillen

Reputation: 828

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

Upvotes: 8

Views: 2791

Answers (2)

Ghadeer Alkubaish
Ghadeer Alkubaish

Reputation: 11

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

imageView.contentMode = .center

Upvotes: 1

a_nub
a_nub

Reputation: 437

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.

Upvotes: 12

Related Questions