Advertisement
Guest User

Untitled

a guest
Dec 27th, 2014
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. class ViewController: UIViewController {
  2.  
  3. @IBOutlet weak var toggleButton: UIButton!
  4. @IBOutlet weak var heightConstraint: NSLayoutConstraint!
  5. @IBOutlet weak var viewB: UIView!
  6. var toggle = false
  7.  
  8.  
  9. @IBAction func toggleBLabelConstraint(sender: AnyObject) {
  10. toggle = !toggle
  11. if toggle{
  12. toggleButton.setTitle("Show B", forState: UIControlState.Normal)
  13. UIView.animateWithDuration(0.3, animations: {
  14. self.viewB.alpha = 0.7
  15. self.heightConstraint.constant -= 70
  16. self.view.layoutIfNeeded()
  17. })
  18. }else{
  19. toggleButton.setTitle("Hide B", forState: UIControlState.Normal)
  20. UIView.animateWithDuration(0.3, animations: {
  21. self.viewB.alpha = 1
  22. self.heightConstraint.constant += 70
  23. self.view.layoutIfNeeded()
  24. })
  25. }
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement