You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
codepath-wiki-review[bot] edited this page Jun 29, 2026
·
6 revisions
It is sometimes necessary to programmatically create views. Follow the steps below to create views.
Step 1: Creating the View
First, decide where you want the view to be and how large you want it to be. Create a frame with the desired dimensions and use that frame to create the view. After you create the view, configure any properties that you want.
Next, you have to add the view into another view. This view can be the main view or any other view in the hierarchy. It's up to you where you want to embed the newly created view.
view.addSubview(blueView)
Adding the subview as above will add the subview on top of the other subviews. You can also insert the subview at an arbitrary z-index.