Advertisement
Guest User

Untitled

a guest
May 25th, 2015
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1. // in viewDidLoad...
  2. var tapGestureRecognizer = UITapGestureRecognizer(target: self, action: "showToolbars")
  3. tapGestureRecognizer.cancelsTouchesInView = false
  4. scrollView.addGestureRecognizer(tapGestureRecognizer)
  5.  
  6. // somewhere else...
  7. func showToolbars() {
  8. UIView.animateWithDuration(1.0, delay: 0.0, options: UIViewAnimationOptions.CurveEaseOut, animations: {
  9. self.toolbar.frame = CGRectMake(0, self.view.frame.size.height-self.toolbar.frame.size.height, self.toolbar.frame.size.width, self.toolbar.frame.size.height)
  10. if self.ios7Patches!.verticalSizeClass == UIUserInterfaceSizeClass.Compact { // iPhone Horizontal
  11. self.navigationController.navigationBar.frame = CGRectMake(0, 0, self.navigationController.navigationBar.frame.size.width, self.navigationController.navigationBar.frame.size.height)
  12. } else {
  13. self.navigationController.navigationBar.frame = CGRectMake(0, 20, self.navigationController.navigationBar.frame.size.width, self.navigationController.navigationBar.frame.size.height)
  14. }
  15. }, completion: {(value: Bool) in})
  16. hideToolbarsTimer?.invalidate()
  17. hideToolbarsTimer = NSTimer.scheduledTimerWithTimeInterval(5.0, target: self, selector: "hideToolbars", userInfo: nil, repeats: false)
  18. }
  19. func hideToolbars() {
  20. hideToolbars(nil, delay: nil)
  21. }
  22. func hideToolbars(duration:NSTimeInterval?, delay:NSTimeInterval?) {
  23. var intDelay : NSTimeInterval
  24. if var thisDelay = delay {
  25. intDelay = thisDelay
  26. } else {
  27. intDelay = 0.0
  28. }
  29. var intDuration : NSTimeInterval
  30. if var thisDuration = duration {
  31. intDuration = thisDuration
  32. } else {
  33. intDuration = 1.0
  34. }
  35. UIView.animateWithDuration(intDuration, delay: intDelay, options: UIViewAnimationOptions.CurveEaseOut, animations: {
  36. self.toolbar.frame = CGRectMake(0, self.view.frame.size.height, self.toolbar.frame.size.width, self.toolbar.frame.size.height)
  37. self.navigationController.navigationBar.frame = CGRectMake(0, -(self.navigationController.navigationBar.frame.size.height), self.navigationController.navigationBar.frame.size.width, self.navigationController.navigationBar.frame.size.height)
  38. }, completion: {(value: Bool) in})
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement