is it possible to switch an app from non full screen to full screen?
I have this switch and I want to make that when turned on the app will hide the status bar, when turned off the app won't hide the status bar
So I've implemented this:
@IBAction func fsChanged(sender: AnyObject) {
if(fullScreenSwitch.on)
{
prefersStatusBarHidden()
println("FS attivato")
}
else {
prefersStatusBarHidden()
println("FS disattivato")
}
}
override func prefersStatusBarHidden() -> Bool {
if(fullScreenSwitch.on)
{
return true
}
else {
return false
}
}
It does work on the actual segue but not in the whole application! How can I make this for ALL the application??
Thank you!
in swift 3, swift 4 you should use it
override open var prefersStatusBarHidden: Bool {
return true
}
can't assign it like this
self.prefersStatusBarHidden = false
it will give you a error
Error: Cannot assign to property: 'prefersStatusBarHidden' is a get-only property
just use a global variable like statusBarIsHidden to hold your desired state
then in each of your view controllers put in the function:
override func prefersStatusBarHidden () -> Bool {return statusBarIsHidden}
//
// ViewController_no_status_bar.swift
// hide the status bar
//
// Created by Scott Yannitell on 4/30/15.
// Copyright (c) 2015 ohiovr.com. All rights reserved.
//
import UIKit
var statusBarIsHidden = true
class ViewController_no_status_bar: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
override func prefersStatusBarHidden () -> Bool {return statusBarIsHidden}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With