You can create custom view using one of the way mentioned in below.
- Using Storyboard
- Using XIB
- Creating views programatically.
what are advantages of Storyboards?
- A nice way to manage how different controllers talk to each other
- Give you a complete look at the flow of your application.
- It’s work well with small apps.
what are disadvantages of Storyboards?
- If you working in a team, Git merge conflicts are usual.
- you can’t create custom inits
- you can’t reuse views.
- To get a full picture of a UI component, you need to inspect both an story board and a source code file
what are advantages of XIB?
- you can reuse views and code
- It’s work well when your working as a team
- It provide visual content and layout of a view
- you can create custom inits
what are disadvantages of XIB?
- Need to create xib for views and custom class separately
- We need to write code for loading xib and establishing relationship between class and xib.
- Resolving merge conflicts in xibs is error-prone
- To get a full picture of a UI component, you need to inspect both an Interface Builder file and a source code file
- There are too many ways of configuring a component via IB: Runtime attributes, multiple tabs with different settings, size-class-specific overrides, etc. This makes it difficult to spot which settings are overridden.
what are advantages of Creating View Programatically?
- The code is easier to debug
- Constraint might be easier to overview
- Code is a single source of truth of a UI component.
- View setup is explicit. It is clear which properties are configured and how.
- Merge conflicts are easier to resolve since we’re dealing with code rather than XML.
- Extensible for complex scenarios: screen rotation, animations, dynamic fonts, etc.
- In complex scenarios, when you need more control over the layout (e.g., screen rotation, variations per screen size or platform, animations, dynamic fonts), you’ll need to resort to programmatic constraints or even manual frame calculation.
what are disadvantages of Creating View Programatically?
- There is no visual representation of views
- might end up with lot of layout code.
I hope you find this blog helpful. If you enjoyed it, feel free to hit the clap button below 👏 to help others find it! and follow me on Medium. Thanks for reading. ❤❤❤❤