0

I am subclassing an UIView that is being loaded from a xib file. When I load the xib into the Viewcontroller using NSBundle.mainBundle().loadNibName() I want the UIView's width, height and background color to be set. This is what I have in the initializer, but when I run the simulator the UIView does not have a width, height or background color set.

required init(coder aDecoder: NSCoder) {
    super.init(coder: aDecoder)
    self.backgroundColor = UIColor.blueColor()
    self.bounds = CGRect(x: 0, y: 0, width: 150, height: 150)
}
technoY2K
  • 2,442
  • 1
  • 24
  • 38

1 Answers1

0

Override awakeFromNib instead. See this question for a broader explanation.

Community
  • 1
  • 1
Aaron Brager
  • 65,323
  • 19
  • 161
  • 287