Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The masks are the same as when created in IB or code. The thing you want to make sure to do in code though is make sure the frames are set properly proportioned once. In your case, yes you do want UIViewAutoResizingFlexibleTopMargin, and setting the correct y-value on the origin in terms of y = parentView.bounds.size.height - (x points as you described), is all you need to do.</p> <p>EDIT: According to your updated question, maybe this will help you. If the button has a constant size, set the frame to that size with CGPointZero as the origin when you create the button. If a UIView owns the button, then put this code in layoutSubviews. If a UIViewController owns the button, replace self.bounds with self.view.bounds and put this in view(Will/Did)LayoutSubviews (Assuming iOS5+).</p> <pre><code> // Aligning the button at it's current x value, current size, with its bottom border margin pizels from the bottom of the parent view. CGFloat margin = 10; CGRect buttonFrame = button.frame; buttonFrame.origin.y = self.bounds.size.height - buttonFrame.size.height - margin; button.frame = buttonFrame; </code></pre> <p>Also, define constant values at the top of the implementation file. Feel free to create convenience methods for readability (if you find this more readable and not doing too much on one line) such as </p> <pre><code> CGRect CGSetYInRect(CGFloat y, CGRect rect) ... button.frame = CGSetYInRect(self.bounds.size.height - button.frame.size.height - margin, button.frame); </code></pre> <p>Use AutoResizing when appropriate to avoid explicit logic in layoutSubviews.</p> <p>When you move to iOS 6 + only, use AutoLayout.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload