Reputation: 3517
I'm getting an error for self.view saying 'UIViewController.Type' does not have a member named 'view'
extension UIViewController {
class func addBackgroundImage() {
let backgroundImageView = UIImageView();
let backgroundImage = UIImage(named: "splashBackground");
backgroundImageView.image = backgroundImage;
self.view.addSubview(backgroundImageView);
let insets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
backgroundImageView.autoPinEdgesToSuperviewEdgesWithInsets(insets)
}
Upvotes: 1
Views: 87
Reputation: 14020
You have defined addBackgroundImage
as a class func
. This means self
will be the class object, not an instance of the class.
Use func addBackgroundImage() { ... }
instead.
Upvotes: 2