如何设置使用SWIFT在X code语言背景图像? [英] How to set a background image in Xcode using swift?

查看:165
本文介绍了如何设置使用SWIFT在X code语言背景图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何设置背景图片使用Swift在X code 6我主视图控制器?我知道,你可以在助理编辑如下做到这一点:

 覆盖FUNC viewDidLoad中(){
        super.viewDidLoad()
        self.view.backgroundColor = UIColor.yellowColor()
}

什么是code设置背景​​图片我已经在我的资产文件夹?


解决方案

 覆盖FUNC viewDidLoad中(){
    super.viewDidLoad()
    self.view.backgroundColor =的UIColor(patternImage:UIImage的(命名为:background.png))
}

How can I set a background image for my main view controller in Xcode 6 using swift? I know that you can do this in the assistant editor as below:

Override func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor = UIColor.yellowColor()
}

What is the code to set the background to an image I have in my assets folder?

解决方案

override func viewDidLoad() {
    super.viewDidLoad()
    self.view.backgroundColor = UIColor(patternImage: UIImage(named: "background.png"))
}

这篇关于如何设置使用SWIFT在X code语言背景图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆