I would like to create a custom UIView so I could use it among a few UIViewControllers.
I created a xib file that looks like this:
The Above image has UIView, and inside 3 UIButtons
- I created TopBar : UIView
- I set the view size to freeform and the status bar to no.
- I set the File's Owner class to TopBar
- I dragged the UIView (which includes the 3 UIButtons) and called it contentView
- I added in TabBar.m the method:
-(void)awakeFromNib {
[[NSBundle mainBundle] loadNibNamed:@"TopBar" owner:self options:nil];
[self addSubview: _contentView];
}
- I added to my UIViewController via storyboard the UIView and set its class to TopBar and its size to the UIView size in the xib
However, the result looks like this:
Why? What is wrong? (as you can see the buttons are extremely big and have spaces between them). I am supporting only Ios6 and above