Skip to content

Instantly share code, notes, and snippets.

@cocoaNib
Created July 22, 2015 08:34
Show Gist options
  • Save cocoaNib/774a1eef1e287733490a to your computer and use it in GitHub Desktop.
Save cocoaNib/774a1eef1e287733490a to your computer and use it in GitHub Desktop.
Toggle StatusBar Example
//
// ToggleStatusBarViewController.swift
// UIKitExamples
//
// Created by Renate Wünschl on 22.07.15.
// Copyright (c) 2015 cocoanib. All rights reserved.
//
import UIKit
class ToggleStatusBarViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
override func prefersStatusBarHidden() -> Bool {
return !UIApplication.sharedApplication().statusBarHidden
}
override func preferredStatusBarUpdateAnimation() -> UIStatusBarAnimation {
return UIStatusBarAnimation.Slide
}
@IBAction func toggleStatusBar(sender: UIButton) {
UIView.animateWithDuration(0.5,
animations: {
self.setNeedsStatusBarAppearanceUpdate()
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment