定义UIImage将使用的文件(Swift) [英] Defining the file a UIImage will use (Swift)
问题描述
所以我浏览了苹果网站上的开发者库,我找不到任何文档说明如何使用swift语言来说明用于UIImage的文件(如png)。
所以我尝试使用这段代码:
So I looked around the developer library on apple's site and I couldn't find any documentation that said how to state what file (like a png) to use for a UIImage using the swift language. So I try experimenting with this code:
class ViewController: UIViewController {
@IBOutlet var maintitle: UIImageView
var bigtitle: UIImage!
var smalltitle: UIImage!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
func startAnimating(){
var animatedtitle: AnyObject[] = [bigtitle, smalltitle]
var animationDuration: NSTimeInterval = 0.15
var animationRepeatCount: Int = 0
}
}
我试图做的是动画永无止境系列的两个图像。我定义了两个UIImages(bigtitle& small title),并且想知道如何定义用于那些UIImage的wat .png。我知道这是一个非常基本和新手的问题,但任何帮助都会很愉快。
What I was trying to do there was animate a never ending series of two images. I defined two UIImages (bigtitle & small title) and was wondering how I define wat .png's to use for those UIImage's. I know this is a very basic and novice question but any help would be enjoyed.
推荐答案
即使您使用的是Swift,所有来自 UIKit
的类和其他库仍然是用Objective-C编写的。
Even though you are using Swift, all the classes that come from UIKit
and other libraries still are written in Objective-C.
没有区别这些库的接口,只是语法。
There is no difference in the interfaces to these libraries, just the syntax.
在这种情况下,您需要使用对象构造语法:
In this case, you need to use the object construction syntax:
var image = UIImage(named:"ImageName")
这篇关于定义UIImage将使用的文件(Swift)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!