How to create sub class UIView with xib?


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.

  1. You need to create your subclass: File -> New -> File -> Cocoa Touch -> Objective C-class -> Subclass of Target Class Type (UIView on your case)
  2. Then, you create the xib for it: File > New > User Interface > View (name your xib)
  3. Now go and design your xib on the Interface Builder.
  4. Last thing you should do is to change your view's Class Type in Identity Inspector. Your custom xib will be linked with your custom class.

Let me know if you need further detail.