Difference between view's frame and view's bound + iPhone - iphone

I want to know what is the difference between 'frame' and 'bound' property of UIView. I get the same results using both properties. I can not figure out the difference between the two..
Thanx in advance.

The frame is the view's location in its superview, using the superview's coordinate system.
The bounds is the view's location and size in its own coordinate system.
If you are getting the same results for both properties, it means that the view fills its superview, and both views have (0, 0) as the origin. Try changing the frame, and you will see it move to different positions within its superview.

This is covered in the documentation. The frame and bounds are two different coordinate systems.

I know its too late but as this a common question so I am posting a link to apple documentation to have a detailed explanation on this

Related

How to get the correct frame of a rotated UIView (including correct position)

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?
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.

Is there a way to literally pause the view?

Can I pause a view for a certain amount of time? Basically, while an action is occurring, my view becomes messed up and I cannot figure out why. Everything gets shifted, and I've been looking through the code line by line for hours. So can I prevent the view from changing itself and then somehow resume it after the action is over? I really don't know if this is a stupid question, but thanks for your help!
The action is sending something to a server, for whatever reason the
entire view is shifted. After the view is shifted, I have the
coordinates outputted to the log, and it thinks the view is at 0,0,
even though it's not.
I think you might be getting mixed up in the distinction between frames & bounds?
From this link
The frame of an UIView is the rectangle, expressed as a location (x,y)
and size (width,height) relative to the superview it is contained
within.
The bounds of an UIView is the rectangle, expressed as a location
(x,y) and size (width,height) relative to its own coordinate system
(0,0).
Essentially, if you're looking at the origin coordinates of the bounds of your view, it will always be 0,0. Instead, you should look at its frame coordinates. I hope this helps you in figuring out the problem.
No, there's no general mechanism for preventing changes to a view. If the view in question is your own UIView subclass, you can of course override the methods that modify the view and effectively prevent changes that way. That'd be a lot of work, however, and I don't think the result would be worth the effort; you'll be much better off finding the real problem and fixing it. It's always easier and better to work with the framework and not against it.

UIKit: CGAffineTransforms and Composited Animations

I've noticed that when animating things in UIKit, certain types of animations can be composited using standard block-based animations while others cannot. For instance, view.transform interferes with view.frame, but not with view.center. Are these things documented anywhere?
On a related note, because of these compositing issues, I've often resorted to animating mainly using CGAffineTransforms, since they can be composited very easily. Is this a good idea? It seems that applying a transform is different under the hood than simply changing the frame, so I'm not sure if I should be using them to permanently move a view or change its size. Do CGAffineTransforms and view.frame-related changes overlap at all?
Thanks!
For what it's worth, here's Apple's stance on this:
You typically modify the transform property of a view when you want to
implement animations. For example, you could use this property to
create an animation of your view rotating around its center point. You
would not use this property to make permanent changes to your view,
such as modifying its position or size a view within its superview’s
coordinate space. For that type of change, you should modify the frame
rectangle of your view instead.
Source: View Programming Guide for iOS, View and Window Architecture
(I suppose one exception would be permanently rotated views, which would be impossible to accomplish with frame modifications.)
I've also determined that CGAffineTransforms appear to modify the underlying rendered image of a view, not its content, so (for example) applying a CGAffineTransformScale is fundamentally different from expanding the frame. I'm not sure if this is necessarily true, or if it depends on contentMode/other factors.
I'm still not entirely clear on how the frame, bounds, and transform of a view interact. You can, for example, set the frame of a view after applying a rotation, and it'll be relative to the rotated view, whereas modifying the bounds will apply the transformation to the view pre-rotation (IIRC).

How do I position a subview within a principal view?

I created a class in my project and this class is a subclass of another class; I want place this subview in the principal view, I reduced x and y to make it smaller, but it always appears at the top left, how can I set it in other position?
Would be easier to answer if you posted some code. Most likely, you need to modify the frame property of your view. frame is a rectangle (CGRect) that determines the position and size of your view in the coordinate system of its superview. The bounds property is similar but expresses origin and size in the coord system of itself (e.g. origin is 0,0).
For other layout tips, look at the autoresizingMask and contentMode properties of views. In fact, read up on views in general. The Apple docs are good and lots of stuff here about them.

How to detect Collision Between two UIImageViews belonging in two different UIViews?

I am noob in Iphone programming, so please help.
I am rotating 2 Views in opposite direction in circular way. Now I want to find out when both images are intersected.
As of now I am rotating view not Image so CGRectIntersectsRect() won't give me the desired result. Is there any other way I can get the solution i.e. intersection of both images ?
My problem is both are in different views. Any idea or suggestion or code snippet would be great to work further towards my goal.
--Edited--
I have 2 views in one view 1st image in another 2nd image. I am rotating both views in different direction circular. there will be one time when both image will be at same location. I am unable to use CGRectIntersectsRect() as both are in different views.
How do I know that both image met at location ? i.e. Collision occurred. Please forgive abt not providing clear explanation about question.
Try this method to convert the rect in the view to the rect in window coordinates, then use CGRectIntersectsRect() . Hope this works for you.
Converts a rectangle from the
receiver’s coordinate system to that
of another view.
(CGRect)convertRect:(CGRect)rect toView:(UIView *)view
Parameters rect A rectangle in the
receiver's coordinate system. view The
view that is the target of the
conversion operation. If view is nil,
this method instead converts from
window base coordinates. Otherwise,
both view and the receiver must belong
to the same UIWindow object. Return
Value The converted rectangle.