Search code examples
objective-cioscocoainterface-buildercgrect

CGRect Assistant?


This is a little vague, but i'll try to be specific.

How do you use CGRect and CGRectMake? Is there an assistant or something which you can use to find points quickly? I've looked in Interface Builder, but it seems to me that there is no quick way of finding the points to use in CGRect. If anyone could point me in the right direction, it would be great.


Solution

  • If you're trying to recreate an interface in code that's in interface builder, you need to look at the Size Inspector:

    First, select an element in interface builder:

    enter image description here

    Now look at the Size Inspector in the right-side panel:

    enter image description here

    The X, Y, Width and Height variables give you enough information to create a CGRect with the same size as the element:

    CGRect editFrame = CGRectMake(233.0, 6.0, 67, 32);