我需要用NSSlider控制上传的图片(JPEG,PNG,TIFF等)的透明度(或不透明度)。我该怎么做呢?下面是用AppDelegate编写的代码。swift
@IBAction func importButton(sender: AnyObject) {
let uploadFile: NSOpenPanel = NSOpenPanel()
uploadFile.allowsMultipleSelection = false
uploadFile.canChooseFiles = true
uploadFile.canChooseDirectories = false
uploadFile.runModal()
let chosenPicture = uploadFile.URL
if(chosenPicture != nil) {
let pictureImport = NSImage(contentsOfURL: chosenPicture!)
imageWell.image = pictureImport
}
}
@IBAction func brightnessSlider(sender: AnyObject) {
//var alpha = sender...
}
1条答案
按热度按时间fd3cxomn1#
试试这个
如果
minValue
始终为0,则alpha的计算会变得更简单: