Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding background to ios app in xcode 6 using Swift

I am new to ios development so please forgive me. I am taking it step by step and I was wondering how would I make a image I want to be the background in the view controller so I can add on top of it?

like image 376
user3411711 Avatar asked Jun 24 '26 09:06

user3411711


2 Answers

If you want to do it programmatically using swift here is the code:

 self.view.backgroundColor = UIColor(patternImage: UIImage(named: "yourImage.png"))

Or you can create a uiimage and place your image in it:

let yourImage = UIImage(named: "yourImage.png")
let imageview = UIImageView(image: yourImage)
self.view.addSubview(imageview)
like image 187
euthimis87 Avatar answered Jun 27 '26 03:06

euthimis87


Add a UIImageView to your view controller's view. Assign your background image to the image view. You can do all this in the storyboard file.

Good luck!

like image 22
Daniel T. Avatar answered Jun 27 '26 02:06

Daniel T.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!