adjusting label to slider value swift

后端 未结 6 645
清歌不尽
清歌不尽 2021-01-01 14:34

I have a slider and label in my swift project. On the storyboard, I control dragged my slider onto my controller class for that page and created an outlet and also an action

6条回答
  •  生来不讨喜
    2021-01-01 15:17

    class ViewController: UIViewController {

    @IBOutlet weak var imgView: UIImageView!
    @IBOutlet weak var slideroutlet: UISlider!
    @IBOutlet weak var lblValue: UILabel!
    
    override func viewDidLoad() {
        super.viewDidLoad()
    
    }
    
    @IBAction func slider(_ sender: Any) {
    
        lblValue.text = String(slideroutlet.value)
        imgView.alpha = CGFloat(slideroutlet.value)
    }
    

提交回复
热议问题