Created
January 11, 2016 19:36
-
-
Save maxcampolo/557744a5e38421d17d7f to your computer and use it in GitHub Desktop.
Animate the application status bar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func animateStatusBarHidden(hidden: Bool) { | |
let key = NSString(data: NSData(bytes: [0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x42, 0x61, 0x72] as [CUnsignedChar], length: 9), encoding: NSASCIIStringEncoding) | |
let object = UIApplication.sharedApplication() | |
var statusBar: UIView? | |
if let mKey = key as? String { | |
if object.respondsToSelector(NSSelectorFromString(mKey)) { | |
statusBar = object.valueForKey(mKey) as? UIView | |
} | |
} | |
if let mStatusBar = statusBar { | |
if hidden { | |
UIView.animateWithDuration(0.2, animations: { () -> Void in | |
mStatusBar.transform = CGAffineTransformMakeTranslation(0.0, -20) | |
}) | |
} else { | |
UIView.animateWithDuration(0.2, animations: { () -> Void in | |
mStatusBar.transform = CGAffineTransformMakeTranslation(0.0, 0.0) | |
}) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment