Friday 12 May 2017

UIView Hide/Show with animation



function: 

 func setView(view: UIView, hidden: Bool) {
     UIView.transition(with: view, duration: 0.5, options: .transitionCrossDissolve, animations: { _ in
          view.isHidden = hidden
     }, completion: nil) 

}

usage:


@IBOutlet weak var updateprofileview: UIView!

 @IBAction func updateProfileViewAction(_ sender: Any) {
        
        if updateprofileview.isHidden {
            setView(view: updateprofileview, hidden: false)
        } else {
            setView(view: updateprofileview, hidden: true)
        }
    }


note: design view in stack view 

No comments:

Post a Comment

Remove bottom line in navigation bar

navigationController ?. navigationBar . setBackgroundImage ( UIImage (), for: . any , barMetrics: . default )          navigat...