ios - Add UIView to Storyboard without a XIB file -
i attempting add uiview without nib file storyboard. have dragged uiview onto storyboard , changed it's class "jahreskalender" jahreskalender class follows:
class jahreskalender: uiview { override func drawrect(rect: cgrect) { // drawing code self.opaque = false self.backgroundcolor = uicolor(red: 100, green: 1, blue: 5, alpha: 0) let jahresview = uiimageview(image: uiimage(named: "calender.png")) jahresview.frame = cgrect(x: 0, y: 0, width: 100, height: 100) self.addsubview(jahresview) } }
when run app black rectangle have dragged uiview. need load xib file or can "jahreskalender" class programmaticall? looked everywhere can't find tutorials.
well, after more trial , error found mistake. need call init(coder adecoder: nscoder).
required init(coder adecoder: nscoder) { super.init(coder: adecoder) self.opaque = false }
now works. tips!
Comments
Post a Comment