How to Set Screen Image in All iPhoneScreens

I created a programmatically constrained image view

let imgName = "2017-01-18-2.png"
    let image = UIImage(named: imgName)
    let imgView = UIImageView(image: image!)

    imgView.frame = CGRect(x: 0, y: 0, width: 365, height: 667)
    view.addSubview(imgView)

      

But when I run in iPhone 5s it comes in full view (Image in full screen) If I work in iPhone 7 then it comes (image LilbitUp) I searched all the previous questions, but all people say they create constraints in the storyboard but I want to do with software. If any help would be appreciated Thanks. Advance

+3


source to share


2 answers


In Objective-c



UIview.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)

      

+2


source


try it



imgView.frame = CGRect(x: 0, y: 0, width: view.frame.width, height: view.frame.hight)

      

+4


source







All Articles