Toggling the Status Bar using an iOS FireMonkey application

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.

5 Responses to “Toggling the Status Bar using an iOS FireMonkey application”

  1. rocode Says:

    How do fullscreen after the Hide Status Bar?

  2. Anders Ohlsson Says:

    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.

  3. rocode Says:

    thank you

  4. Jérôme Hatton Says:

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

  5. Anders Ohlsson Says:

    Awesome! Please keep me posted!

Leave a Reply


Bad Behavior has blocked 512 access attempts in the last 7 days.

Close