Hope the title was clear. I want to hide an element (data collector in my case), and also I want to hide my space. So I tried this with animation:
@IBAction func showQnt(sender: AnyObject) { if (self.pickerQnt.alpha == 0.0){ UIView.animateWithDuration(0.2, delay: 0.0, options: UIViewAnimationOptions.ShowHideTransitionViews, animations: { self.pickerQnt.alpha = 1.0 }, completion: { (finished: Bool) -> Void in //var constH = NSLayoutConstraint(item: self.pickerQnt, attribute: NSLayoutAttribute.Height, relatedBy: NSLayoutRelation.Equal, toItem: nil, attribute: NSLayoutAttribute.NotAnAttribute, multiplier: 1, constant: 162) //self.pickerQnt.addConstraint(constH) }) } else { UIView.animateWithDuration(0.2, delay: 0.0, options: UIViewAnimationOptions.ShowHideTransitionViews, animations: { self.pickerQnt.alpha = 0.0 }, completion: { (finished: Bool) -> Void in // CHECK: ?!? constrain to set view height to 0 run time //var constH = NSLayoutConstraint(item: self.pickerQnt, attribute: NSLayoutAttribute.Height, relatedBy: NSLayoutRelation.Equal, toItem: nil, attribute: NSLayoutAttribute.NotAnAttribute, multiplier: 1, constant: 0) //self.pickerQnt.addConstraint(constH) }) } }
I also tried something like:
self.pickerQnt.hidden = true
but does not work.
Thanks in advance.
source share