livecode.com
  • Home
  • Download
  • Developers
  • Academy
  • Community
  • Store
  • Support
  • About
LiveCode Lessons » How To - LiveCode Mobile Tasks » How do I Configure the Status Bar in iOS?

Topics

  • Getting Started with Android 3
    • How do I Become an Android Developer on a PC?
    • How do I Become an Android Developer on a Mac?
    • The Basics: How do I Create Hello World on Android?
  • Getting Started with iOS 2
    • How do I Become an iOS Developer?
    • How do I use Core Location in revMobile
  • LiveCode Mobile Tasks 22
    • How do I Develop Cross-Platform in LiveCode?
    • How do I send an email from my mobile device?
    • How do I use multi-touch to move more than one object?
    • How do I use the Question and Password Dialogues in LiveCode Mobile?
    • How do I Capture Images in LiveCode Mobile?
    • How do I detect a shaking motion using LiveCode mobile?
    • LiveCode Mobile Video How-To's - Shake
    • How do I implement a multi-touch pinch motion?
    • LiveCode Mobile Video How-To's - Multi-touch
    • How do I play a video in part of the screen in iOS
    • Displaying Assets On Differing Screen Resolutions
    • How to create and use an SQLite database
    • How do I get an image from my mobile photo library
    • How do I implement in-app purchases in LiveCode?
    • Accessing Facebook Api's using LiveCode
    • Mobile Orientations
    • Using local notifications
    • Using custom URL schemes
    • Using multi-channel audio on mobile
    • How do I get the Location and use the Digital Compass?
    • How do I use Ads in LiveCode?
    • Creating a native scroller to scroll a field
  • iOS Tasks 19
    • How do I build an iPhone application for iOS?
    • How do I Configure the Status Bar in iOS?
    • How do I make a phone call on the iPhone?
    • How do I use Native Text Controls on iOS
    • How do I use the Browser Control?
    • How do I read/write to files in iOS?
    • How do I Send HTML E-Mails with Attachments in iOS?
    • Installing custom fonts on iOS
    • How do I use the Question and Password Dialogues in iOS?
    • How do I play sounds on an iOS device?
    • How do I use the Picker View on an iPhone?
    • How do I Access Maps on iOS?
    • Creating a simple stock control application for the iPad
    • How do I Create a Distribution Profile for iOS?
    • How do I Submit an iOS App to the App Store?
    • How do I set up an App for Submission to iTunes Connect?
    • How do I use the Date Picker View on an iPhone?
    • How do I use Push Notifications with iOS?
    • How do I Develop iOS Code for Standard and Retina Devices?
  • Android Tasks 4
    • Using the hardware "back" button on Android
    • How do I Create an Android App for Distribution?
    • How do I Create a Self-Signed Certificate for an Android App?
    • How do I use Push Notifications with Android?

Last Updated

Aug 18, 2011

Download Lesson PDF

Other Resources

  • Getting Started with LiveCode

  • Get Up and Running with LiveCode
  • Getting Started with LiveCode Development
  • LiveCode Concepts

  • Features, concepts and aspects of LiveCode
  • LiveCode Lessons

  • How To - Step-By-Step Guides To Tasks In LiveCode
  • How To - LiveCode Server Tasks
  • How To - LiveCode Mobile Tasks
  • How To - LiveCode Sample Scripts
  • How to - LiveCode Marketplace Products
  • How to Purchase and License LiveCode
  • Tutorials

  • Creating a Video Library Application
  • Data Grid

  • LiveCode Data Grid
  • Data Grid Tips & Tricks
  • Converting the Stock Program

Comments

0 for this lesson

  • Prev: How do I build an iPhone application for iOS?
  • Next: How do I make a phone call on the iPhone?

How do I Configure the Status Bar in iOS?

This lesson describes how to control the style and visibility of the iOS status bar from within an iPhone application.
Sample code is provided.

Introduction

The iOS status bar usually runs along the top of the iPhone window and provides useful information on the status of the device. This can include the current time, the remaining battery life and the carrier strength

For many applications this is a desirable feature, but other applications provide a better user experience when the status bar is hidden or takes on a different form, for example when watching a movie.

As the user interacts with an application and the displayed information changes, for example when switching between a movie mode and a control mode, it man be necessary to toggle the status bar.

Status Bar Visibility and Styles

The status bar is either visible or invisible. When the status bar is visible, it can have one of three styles, either default, opaque or translucent. When the status bar is visible and is either default or opaque, the status bar lies above the content of the application and pushes the application down the screen to make space for the status bar. The application needs to take this behavior into account when controlling the status bar. If the status bar is translucent, the application is allowed to take up the entire display area and the status bar is displayed on top of the application. Parts of the application appear to shine through the status bar.

The Default Status Bar

The status bar in this example is visible and uses the default style.

The Opaque Status Bar

The status bar in this example is visible and uses the opaque style.

The Hidden Status Bar

The status bar in this example is hidden and the application uses the entire display area. Notice the exposed light gray area at the bottom of the screen. This area was not visible in the previous examples as the status bar pushed the application down the screen in order to display the status bar.

The Translucent Status Bar

The status bar in this example is visible and uses the translucent style. You can see how the status bar and the application lie on top of each other. Notice in this example that the application also takes up the entire display area and exposes the light gray area at the bottom of the screen.

Controlling the Status Bar Visibility

The status bar is toggled using the commands iphoneShowStatusBar and iphoneHideStatusBar. To test this feature, you may want to place these commands in a check box with the name StatusBarDisplayed and the following code:

on mouseUp
    if the hilite of button "StatusBarDisplayed" is true then
        iphoneShowStatusBar
    else
        iphoneHideStatusBar
    end if
end mouseUp

Setting the Status Bar Style

The status bar style is set by the command iphoneSetStatusBarStyle, which uses an argument to specify the display style of the status bar. Supported display style arguments are: default, opaque and translucent.
In order to test this feature, you may want to set up three radio buttons in a group and provide the following code for the buttons:

In the first button script write:
on mouseUp
    iphoneSetStatusBarStyle ("default")
end mouseUp

In the second button script write:
on mouseUp
    iphoneSetStatusBarStyle ("opaque")
end mouseUp

In the third button script write:
on mouseUp
    iphoneSetStatusBarStyle ("translucent")
end mouseUp

Catching the Resize Event

An application needs to be aware of resize events as a result of manipulating the status bar. The following example code shows you how to capture resize events and determine the new size of the display area. The display dimensions are written to a text field with the name cardSize. This code can be added to the card script with the name Status Bar Configuration:

on resizeStack pNewWidth, pNewHeigh
    set the text of field "cardSize" to "Card Size:" && \
        the width of card "Status Bar Configuration" & \
        "X" & the height of card "Status Bar Configuration"
end resizeStack

  • Prev: How do I build an iPhone application for iOS?
  • Next: How do I make a phone call on the iPhone?

Comments (0)

Add your comment

E-Mail me when someone replies to this comment
Brought to you by RunRev Ltd, Registered in Scotland, No. SC200728