Reputation: 1903
In android we can create a separate xml layout and can include it in another layout. I want to achieve same in IOS. I want to create a custom layout and want to include it programmatically to another layout.
How to do it with IOS?
I am using Xcode with swift 2.3.
Upvotes: 1
Views: 257
Reputation: 813
Yes you can do it. First of all you have to create simple fileName.swift file
select this one.
Give class Name as your file name (Here i gave sample) and choose UIView (Because we are creating a simple View.)
Now again Create View (it will create a .xib file where you can design your layout)
Now you select View and create your UI like this.
now open sample.swift (Here) and write simple code.
now you can use this view to add any where in your project. To add this add simple View in any StoryBoard ViewController (Drag and Drop)
Now Main Step to add your Custom View in your View Select your View from ViewController (where you want to add this) and simple Write class name in identity Inspector.
Now Simple Run the project and Bingo..
Upvotes: 2
Reputation: 1538
If you want to build view programmatically you might want to user
https://github.com/SnapKit for swift.
https://github.com/SnapKit/Masonry for objc.
Upvotes: 1
Reputation: 3682
In iOS we called them views.
You can use addSubView
to add another view inside a view.
Example:
[self.view addSubView: yourcustomView]; //Where self.view is the parent view.
Upvotes: 0