What are different ways that you can specify the layout of elements in a UIView?

Here are a few common ways to specify the layout of elements in a UIView:

  • Using InterfaceBuilder, you can add a XIB file to your project, layout elements within it, and then load the XIB in your application code (either automatically, based on naming conventions, or manually). Also, using InterfaceBuilder you can create a storyboard for your application.

  • You can your own code to use NSLayoutConstraints to have elements in a view arranged by Auto Layout.

  • You can create CGRects describing the exact coordinates for each element and pass them to UIView’s - (id)initWithFrame:(CGRect)frame method.