I have an array with my Image-names and a button. When I click on the button, the background-image schould get chaged. All is working but the pictures are a little bit zoomed and are not scaled to screen size.
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
var imagesArray = ["1", "2", "3", "4"]
@IBAction func changeBackgroundImageButton_Tapped(_ sender: UIButton) {
if let randomImage = imagesArray.randomElement(){
view.backgroundColor = UIColor(patternImage: UIImage(named: randomImage)!)
}
}
}
So what should I do that the background-images are not zoomed and scaled perfectly? Thanks!