[英]How to add a image in background in my view in swift?
I'm trying add a image background in my viewController of my Swift app, but colorWithPatternImage is unavailable.. there are other form for this or is necessary add this into a imageView? 我正在尝试在我的Swift应用程序的viewController中添加图像背景,但colorWithPatternImage不可用..还有其他形式或者必须将其添加到imageView中吗?
I'm trying make this with this code: 我正在尝试使用此代码:
let imageName = "image.png"
self.view.backgroundColor = UIColor.colorWithPatternImage(UIImage(named:imageName))
Thanks! 谢谢!
您应该使用UIColor init方法:
view.backgroundColor = UIColor(patternImage: UIImage(named:imageName))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.