2

Steps to reproduce:

  1. Create class like MyIcon below;

  2. Drag a UIView onto storyboard (background is white);

  3. Set UIView's custom class to MyIcon; and

  4. Background color disappears.

MyIcon.swift:

import UIKit
@IBDesignable class MyIcon: UIView {}

See storyboard screenshot below for evidence of loss of white background color:

enter image description here

Joseph Beuys' Mum
  • 2,395
  • 2
  • 24
  • 50

1 Answers1

0

Probably it's a missing init function in the MyIcon class.
@IBDesignable needs at least these two functions:

required init?(coder aDecoder: NSCoder) {
    super.init(coder: aDecoder)
}

override init(frame: CGRect) {
    super.init(frame: frame)
}

To make sure, you can also have a look at the crash reports in /Users/{yourusername}/Library/Logs/DiagnosticReports/

Hugo B.
  • 471
  • 1
  • 8
  • 23