As others have said, you cannot do this solely in IB / storyboard. But with @IBDesignable, you can add a few lines to your subclass and show it in IB, which is pretty cool.
import UIKit @IBDesignable class MyView: UIView { override func awakeFromNib() { super.awakeFromNib() self.addPattern() } override func prepareForInterfaceBuilder() { self.addPattern() } private func addPattern() { let image = UIImage(named: "MyPattern", in: Bundle(for: self.dynamicType), compatibleWith: nil) self.backgroundColor = UIColor(patternImage: image!) } }
Then just change the storyboard / IB class to MyView.
John scalo
source share