Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-15284

iOS7: Support Programmatically Changing the Status Bar Style

    Details

      Description

      The Problem

      Right now, Ti.UI.Window's statusBarStyle can only be specified during creation. Once the window is open, you can't change it. This prevents simple use cases like night and day reading modes for an app (black background, white background).

      The Solution

      Expose setStatusBarStyle on Ti.UI.Window, which calls TiRootViewController's updateStatusBar, and change updateStatusBar to use the main thread.
      https://github.com/appcelerator/titanium_mobile/pull/4709/files

      Example

      var isDayMode = true,
      	ios = Ti.Platform.name === 'iPhone OS',
      	iosFlat = ios && +Ti.Platform.version >= 7,
      	win = Ti.UI.createWindow({
      		backgroundColor: '#fff'
      	}),
      	label = Ti.UI.createLabel({
      		text: 'Day Mode', textAlign: 'center',
      		color: '#000', font: { fontSize: 30 },
      		top: iosFlat ? 60 : 30, bottom: 0
      	}),
      	button = Ti.UI.createButton({
      		title: 'Switch',
      		color: '#000',
      		top: iosFlat ? 30 : 0, height: 30
      	});
      button.addEventListener('click', function() {
      	isDayMode = !isDayMode;
      	if (isDayMode) {
      		ios && (win.statusBarStyle = Ti.UI.iPhone.StatusBar.GRAY);
      		win.backgroundColor = '#ccc';
      		label.color = button.color = '#000';
      		label.text = 'Day Mode';
      	}
      	else {
      		ios && (win.statusBarStyle = Ti.UI.iPhone.StatusBar.TRANSLUCENT_BLACK);
      		win.backgroundColor = '#444';
      		label.color = button.color = '#fff';
      		label.text = 'Night Mode';
      	}
      });
      win.add(label);
      win.add(button);
      win.open();

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                vduggal Vishal Duggal (Inactive)
                Reporter:
                dtoth Dawson Toth
              • Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Backbone Issue Sync is enabled for your project, but we do not have any synchronization info for this issue.

                    Git Integration