How can I animate displaying UIPickerView after pressing button?

后端 未结 6 1328
日久生厌
日久生厌 2021-02-03 13:38

I want to animate my UIPickerView after pressing the button. I already have coded my UIPickerView to be hidden on viewDidLoad and not hidden after pressing a button, but it does

6条回答
  •  爱一瞬间的悲伤
    2021-02-03 13:41

    Swift 3 Solution

    I agree with @EshwarChaitanya, the alpha property is animatable and this is an appropriate use.

    override func viewDidLoad() {
        super.viewDidLoad()
        
        timersPickerView.alpha = 0
    }
    
    @IBAction func selectTimer() {
        UIView.animate(withDuration: 0.3, animations: {
            self.timersPickerView.alpha = 1
        })
    }
    

    I am not sure how you want to hide it so I will leave it up to you.

提交回复
热议问题