Adding A Background Image In Interface Builder

后端 未结 6 2188
庸人自扰
庸人自扰 2021-02-19 06:34

I\'m trying to add a custom image as a background for my application using Xcode 4.2, but I\'m not too sure how to do it. I can add plain colors as the background in Interface B

6条回答
  •  灰色年华
    2021-02-19 07:08

    Swift 3.0 :

    Above code for swift 3.0 is

    import UIKit
    @IBOutlet weak var mainUIView: UIView!
    
    
    class fileName: UIViewController {
    
        override func viewDidLoad() {
            super.viewDidLoad()
    
        mainUIView.backgroundColor = UIColor(patternImage: UIImage(named: "your_image_name.png")!)
    
       }
    }
    

    Hope it Helps Some1 =]

    if you're using Autolayout then you have to struggle a lot coz the image which you're going to add to the background, will not set itself perfectly , as we're doing Programmatically !

    If anyone finds an answer of this question, and can be done by interface builder.. Than It would be helpful for all of us =D..

    Lastly Add a ImageView to that view ,that'll do the job.

提交回复
热议问题