I have an app where I have a rectangle that the user can rotate and pan using their fingers. I'd simply like to know what the frame is of this rotated view so I can find out if it intersects another rectangular UIView
(can't use the frame property because it gets invalidated when the UIView gets transformed). What's the easiest way to accomplish this?
Asked
Active
Viewed 178 times
0

Ser Pounce
- 14,196
- 18
- 84
- 169
-
can you post your transformation code...??? – Venk Mar 26 '13 at 06:14
-
self.rotateAngle = rotateAngle; self.transform = CGAffineTransformMakeRotation(self.rotateAngle); – Ser Pounce Mar 26 '13 at 06:16
-
try view.bounds it may help you. – SAMIR RATHOD Mar 26 '13 at 06:19
-
are you doing this in animation block???? – Venk Mar 26 '13 at 06:24
-
after the normal transformation i can get the frame using `frame` property.... – Venk Mar 26 '13 at 06:24
-
@MountainLion it says in the docs that after a transformation the frame is invalidated, so would like to avoid using that anyway just in case changes in iOS, thanks for taking a look though. – Ser Pounce Mar 28 '13 at 23:13
1 Answers
0
Every UIView
has a property frame
which is of type CGRect.
You can access it using view.frame
.
After the transform is applied you can use the bounds and center property on the view to get the orientation. It may take a little bit of calculation but i hope you can get to it easily.
Refer to this image from an answer to this question.
-
The frame property gets invalidated when there is a transformation. – Ser Pounce Mar 26 '13 at 06:13
-
-
Side note (just in case): Please don't migrate spam (re: *Can a unlocked iphone use an pre-paid sim card with rogers?*). Also, don't vote to migrate when you don't know the target site's faq. Phone and phone service questions are off topic for [su]. Thanks. – Mar 27 '13 at 12:07