Reputation: 1320
I want to create UIView commonly. And use that view in all the view controllers. How can create the UIView sub class with xib and use in all the view controllers? Thanks in advance.
Upvotes: 5
Views: 5291
Reputation: 2210
File -> New -> File -> Cocoa Touch -> Objective C-class -> Subclass of Target Class Type
(UIView on your case)xib
for it: File > New > User Interface > View
(name your xib)xib
on the Interface Builder
.Identity Inspector
. Your custom xib will be linked with your custom class.Let me know if you need further detail.
Upvotes: 7
Reputation: 14304
A UIView subclass first of all must consist of some code defining it, regardless of how you're going to use this view. After you create this class, in order to use it you only need to define the class name in the Interface Builder. Select the UIView you added and change it's class name in the object inspector.
Keep in mind that new properties or functionality that you are adding to this UIView will not be accessible by editing the xib, but only by code.
Upvotes: 1