通过UISlider改变图片的透明度(Swift)

通过UISlider改变图片的透明度(Swift)_第1张图片

//ViewController.swift

import UIKit
//通过滑块改变图片透明度
class ViewController: UIViewController {
//图片
@IBOutlet weak var image1: UIImageView!
//UISlider
@IBAction func slider1(_ sender: UISlider) {
//赋值
image1.alpha=CGFloat(sender.value);
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

}

你可能感兴趣的:(通过UISlider改变图片的透明度(Swift))