Toggling the Status Bar using an iOS FireMonkey application

Posted by on in Blogs
Q: How do I turn on/off the Status Bar on the iPhone?
A: By calling setStatusBarHidden

Below, a simple unit that shows how to toggle the status bar using different animations - none, fade, and slide. The example also shows how to toggle the network activity indicator.

unit Unit1;

{$IFDEF FPC}
{$mode objfpc}{$H+}
{$modeswitch objectivec1}
{$ENDIF}

interface

uses
SysUtils, Types, UITypes, Classes, Variants, FMX_Types, FMX_Controls, FMX_Forms,
FMX_Dialogs
{$IFDEF FPC}
, iPhoneAll
{$ENDIF}
;

type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.lfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
{$IFDEF FPC}
UIApplication.sharedApplication.setStatusBarHidden(not UIApplication.sharedApplication.isStatusBarHidden);
{$ENDIF}
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
{$IFDEF FPC}
UIApplication.sharedApplication.setStatusBarHidden_withAnimation(not UIApplication.sharedApplication.isStatusBarHidden,UIStatusBarAnimationFade);
{$ENDIF}
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
{$IFDEF FPC}
UIApplication.sharedApplication.setStatusBarHidden_withAnimation(not UIApplication.sharedApplication.isStatusBarHidden,UIStatusBarAnimationSlide);
{$ENDIF}
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
{$IFDEF FPC}
UIApplication.sharedApplication.setNetworkActivityIndicatorVisible(not UIApplication.sharedApplication.isNetworkActivityIndicatorVisible);
{$ENDIF}
end;

end.



Comments

  • Guest
    rocode Sunday, 12 February 2012

    How do fullscreen after the Hide Status Bar?

  • Guest
    Anders Ohlsson Monday, 13 February 2012

    I haven't tried it yet. Things I would try include maximizing the form, changing the height and/or repositioning the form to the new top coordinates.

  • Guest
    rocode Tuesday, 14 February 2012

    thank you

  • Guest
    Jérôme Hatton Monday, 9 April 2012

    Hi,
    I try all methods to pom put the form in fullscreen but don't reach to resize the form.
    Any Idea ?

  • Guest
    Anders Ohlsson Wednesday, 1 August 2012

    Awesome! Please keep me posted!

  • Please login first in order for you to submit comments
  • Page :
  • 1

Check out more tips and tricks in this development video: