What am I looking for? Anchor control to top left?

Discussion in 'Mac Programming' started by MythicFrost, Jul 3, 2010.

  1. MythicFrost macrumors 68040

    MythicFrost

    Joined:
    Mar 11, 2009
    Location:
    Australia
    #1
    Hi,

    I've got a NSTextField that I've added to my window:
    Code:
    lConvert = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 100, 20)];
    But, it shows up at the bottom left of the screen, when in my mind it should be at the top left.

    I thought I might need to anchor it (I'm not sure the proper term, but it's in interface builder, Size & Position, just above AutoResizingMask).

    I've looked through the documentation for this and I can't find it, any idea's?

    Kind Regards
     
  2. kpua macrumors 6502

    Joined:
    Jul 25, 2006
    #2
    By default, a view's origin is bottom-left. To get the origin to be in the top-left, you have to override the superview's -isFlipped method and return YES.
     
  3. MythicFrost thread starter macrumors 68040

    MythicFrost

    Joined:
    Mar 11, 2009
    Location:
    Australia
    #3
    Thank you, I realised how to get it up the top without doing so. My code was pushing it up too high so I couldn't see it, which is fixed now.
     

Share This Page