Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // in viewDidLoad...
- var tapGestureRecognizer = UITapGestureRecognizer(target: self, action: "showToolbars")
- tapGestureRecognizer.cancelsTouchesInView = false
- scrollView.addGestureRecognizer(tapGestureRecognizer)
- // somewhere else...
- func showToolbars() {
- UIView.animateWithDuration(1.0, delay: 0.0, options: UIViewAnimationOptions.CurveEaseOut, animations: {
- 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)
- if self.ios7Patches!.verticalSizeClass == UIUserInterfaceSizeClass.Compact { // iPhone Horizontal
- self.navigationController.navigationBar.frame = CGRectMake(0, 0, self.navigationController.navigationBar.frame.size.width, self.navigationController.navigationBar.frame.size.height)
- } else {
- self.navigationController.navigationBar.frame = CGRectMake(0, 20, self.navigationController.navigationBar.frame.size.width, self.navigationController.navigationBar.frame.size.height)
- }
- }, completion: {(value: Bool) in})
- hideToolbarsTimer?.invalidate()
- hideToolbarsTimer = NSTimer.scheduledTimerWithTimeInterval(5.0, target: self, selector: "hideToolbars", userInfo: nil, repeats: false)
- }
- func hideToolbars() {
- hideToolbars(nil, delay: nil)
- }
- func hideToolbars(duration:NSTimeInterval?, delay:NSTimeInterval?) {
- var intDelay : NSTimeInterval
- if var thisDelay = delay {
- intDelay = thisDelay
- } else {
- intDelay = 0.0
- }
- var intDuration : NSTimeInterval
- if var thisDuration = duration {
- intDuration = thisDuration
- } else {
- intDuration = 1.0
- }
- UIView.animateWithDuration(intDuration, delay: intDelay, options: UIViewAnimationOptions.CurveEaseOut, animations: {
- self.toolbar.frame = CGRectMake(0, self.view.frame.size.height, self.toolbar.frame.size.width, self.toolbar.frame.size.height)
- self.navigationController.navigationBar.frame = CGRectMake(0, -(self.navigationController.navigationBar.frame.size.height), self.navigationController.navigationBar.frame.size.width, self.navigationController.navigationBar.frame.size.height)
- }, completion: {(value: Bool) in})
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement