图片名称作为变量(Swift)
Image Name as variables(Swift)
我正在尝试调用一个函数,如下所示,我应该在 load Image() 中写些什么,这样我就可以在调用它时输入不同的图像名称。
非常感谢
func loadImage(????){
self.Picture.image = UIImage (named: "Ch1-4 new.jpg")
UIView.animateWithDuration(3.0,
delay: 0.0,
options: [],
animations : {
let message = "Picture.mp3"
let triggerTime = (Int64(NSEC_PER_SEC) * 1)
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, triggerTime), dispatch_get_main_queue(), { () -> Void in
self.playMessageOpening(message)
})
self.Picture.hidden=false
self.Picture.alpha=0.0;
self.Picture.alpha=1.0;
},
completion: { finished in
print("Picutre done")
})
}
func loadImage(imageName: String) {
self.Picture.image = UIImage (named: imageName)
...
}
其中 imageName
是参数的名称,String
是类型。 the Apple docs.
中有关函数声明的更多信息
我正在尝试调用一个函数,如下所示,我应该在 load Image() 中写些什么,这样我就可以在调用它时输入不同的图像名称。
非常感谢
func loadImage(????){
self.Picture.image = UIImage (named: "Ch1-4 new.jpg")
UIView.animateWithDuration(3.0,
delay: 0.0,
options: [],
animations : {
let message = "Picture.mp3"
let triggerTime = (Int64(NSEC_PER_SEC) * 1)
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, triggerTime), dispatch_get_main_queue(), { () -> Void in
self.playMessageOpening(message)
})
self.Picture.hidden=false
self.Picture.alpha=0.0;
self.Picture.alpha=1.0;
},
completion: { finished in
print("Picutre done")
})
}
func loadImage(imageName: String) {
self.Picture.image = UIImage (named: imageName)
...
}
其中 imageName
是参数的名称,String
是类型。 the Apple docs.