Create a texture background for a view

2.1k views Asked by At

Is there any way we can add or create texture our Xcode 6 project in Swift?

I know how to change the background colors or use rgb's. As an example:

self.view.backgroundColor = UIColor.yellowColor()

But how can we add or create textures for background?

1

There are 1 answers

2
Dave Batton On

Add an image to your Images.xcassets library. Add it to the view like this:

self.view.backgroundColor = UIColor(patternImage: UIImage(named: "MyBackgroundImage")!)