Simple Questions about working with views

Discussion in 'iOS Programming' started by MaxFreud, Aug 2, 2011.

  1. MaxFreud, Aug 2, 2011
    Last edited: Aug 2, 2011

    MaxFreud macrumors newbie

    Jan 5, 2011
    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:
    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:
    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
  2. holmesf macrumors 6502a

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

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

    I tried this out and yeah, it looks like the alpha property does affect how the subviews are drawn.
  3. MaxFreud thread starter macrumors newbie

    Jan 5, 2011
    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."
  4. holmesf macrumors 6502a

    Sep 30, 2001
    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.
  5. MaxFreud, Aug 4, 2011
    Last edited: Aug 4, 2011

    MaxFreud thread starter macrumors newbie

    Jan 5, 2011
    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?

Share This Page