iOS UIView


  1. // Objective-C

  2. [UIView new] // Get a view object allocated and initialized

  3. [[UIView alloc] initWithFrame:(Pass CGRect)] // Get the view allocated and initialized with a frame

  4. [[UIView alloc] init] // Get a view object allocated and initialized

  5. // Swift

  6. UIView() // Creates an UIView instance with frame

  7. UIView(frame: CGRect) // Creates an UIView instance specifying the frame

  8. UIView.addSubview(UIView) // add an another UIView instance as subview

  9. UIView.hidden // Get or set the visibility of the view

  10. UIView.alpha // Get or set the view's opacity

  11. UIView.setNeedsLayout() // Forces the view to update its layout


The UIView class defines a rectangular area on the screen and the interfaces for managing the content in that area. At runtime, a view object handles the rendering of any content in its area and also handles any interactions with that content.