NSView frame rotation and bound rotation

The coordination of the frame of NSView is on its parent view or containers coordinate.
So, that is why the origin of a coordinate a frame is always like ( x, y ) instead of ( 0, 0 ).

While that of bounds of NSView is a separated from its parents. So, it always starts with (0,0).

What does it mean when you are going to rotate frame rect and bound rect?

Let’s try and confirm how they are different.

NSView frame rotation

The rotated frame is drawn over its parent’s view. In other words, it can erode its parent’s view.

How about bound rotation then?

Bound Rotation

Hmm.. Can you see the difference? It is drawn in the parent’s view territory. ( The red dot line shows the frame’s rectangle. So, the small view for displaying image is inside of its parent view, i.e. content view of a NSWindow.

What does this mean?
To rotate content of a view, you need to use [NSView bounds] rather than [NSView frame].
If you are going to rotate objects or images in a view rather than its coordinate system, you will rotate them directly, but when there are many object drawn onto a view, it will be a lot easier to rotate the coordinate system by rotating bounds rather than those objects.

Also, it shows me something interesting. With frame rect, you would be able to draw things outside of a view. This would be necessary when you customize UI widget and control them better.

There is one more thing.
When I tried to rotate a bound, the center of the rotation was not the origin of the bound coordinate. It was the center of the bound rect.

For the frame, I remember it was the origin not the center. I used setFrameRotation: but there is also setFrameCenterRotation:

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: