Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ViewController: UIViewController {
- @IBOutlet weak var toggleButton: UIButton!
- @IBOutlet weak var heightConstraint: NSLayoutConstraint!
- @IBOutlet weak var viewB: UIView!
- var toggle = false
- @IBAction func toggleBLabelConstraint(sender: AnyObject) {
- toggle = !toggle
- if toggle{
- toggleButton.setTitle("Show B", forState: UIControlState.Normal)
- UIView.animateWithDuration(0.3, animations: {
- self.viewB.alpha = 0.7
- self.heightConstraint.constant -= 70
- self.view.layoutIfNeeded()
- })
- }else{
- toggleButton.setTitle("Hide B", forState: UIControlState.Normal)
- UIView.animateWithDuration(0.3, animations: {
- self.viewB.alpha = 1
- self.heightConstraint.constant += 70
- self.view.layoutIfNeeded()
- })
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement