PDA

View Full Version : Simple Questions about working with views




MaxFreud
Aug 2, 2011, 03:06 PM
Dear Cocoaheads,

I am struggling to understand the basics of working with views. I have learned lots from the View Programming Guide, but some ambiguous points remain. Please enlighten me with your wisdom:

1. Point (0,0) is at the top left corner of the screen when the device is help in the normal portrait position. Now, if the device is turned to landscape, where is (0,0)? At the same physical corner, or at the corner that is now top left?

2. There's a little box in the view programming guide that says:
Important: If a view’s transform property does not contain the identity transform, the frame of that view is undefined and so are the results of its autoresizing behaviors.
What does this mean? If I have a view that has a transform applied, how can I have control over its positioning on the screen if not by the use of 'frame'?

(edit) 3. In the UIView class reference, in regards to UIView's 'alpha' property, it says:The value of this property is a floating-point number in the range 0.0 to 1.0, where 0.0 represents totally transparent and 1.0 represents totally opaque. This value affects only the current view and does not affect any of its embedded subviews.[emphasis added] I found in practice, that setting alpha to 0 did affect all subviews. The way I could get a transparent view with translucent content was to set the background to [UIColor clearColor]. Was I missing anything about the alpha property, or is this a documentation mistake?

Thank you



holmesf
Aug 2, 2011, 06:12 PM
Dear Cocoaheads,

I am struggling to understand the basics of working with views. I have learned lots from the View Programming Guide, but some ambiguous points remain. Please enlighten me with your wisdom:

1. Point (0,0) is at the top left corner of the screen when the device is help in the normal portrait position. Now, if the device is turned to landscape, where is (0,0)? At the same physical corner, or at the corner that is now top left?


Top left, assuming the application has actually switched to landscape mode.


2. There's a little box in the view programming guide that says:

What does this mean? If I have a view that has a transform applied, how can I have control over its positioning on the screen if not by the use of 'frame'?



Looks like you're missing a quote from the programming guide here.


(edit) 3. In the UIView class reference, in regards to UIView's 'alpha' property, it says: I found in practice, that setting alpha to 0 did affect all subviews. The way I could get a transparent view with translucent content was to set the background to [UIColor clearColor]. Was I missing anything about the alpha property, or is this a documentation mistake?

Thank you

I tried this out and yeah, it looks like the alpha property does affect how the subviews are drawn.

MaxFreud
Aug 2, 2011, 06:37 PM
Thanks for your reply.


Looks like you're missing a quote from the programming guide here.


This is strange; I can see it. Here's the text: "Important: If a view’s transform property does not contain the identity transform, the frame of that view is undefined and so are the results of its autoresizing behaviors."

holmesf
Aug 2, 2011, 06:46 PM
Thanks for your reply.



This is strange; I can see it. Here's the text: "Important: If a view’s transform property does not contain the identity transform, the frame of that view is undefined and so are the results of its autoresizing behaviors."

Huh, maybe I missed the quote the first time around.

Anyway, you can have control over the positioning of the view from the transform rather than the frame, namely the translation component of the transform.

MaxFreud
Aug 4, 2011, 04:03 PM
Hmm... Ok. Thanks for you response.

So you're saying the tx and ty fields of the transform matrix tell me its position? With respect to what co-ordinate system is this? And, say, if I wanted to put subviews inside of a transformed view, would I create a CGRects with origin.x being the superview's tx + the subview's intended x offset and same for y?