Details
-
Type:
New Feature
-
Status: Closed
-
Priority:
High
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 2013 Sprint 21, 2013 Sprint 21 API, Release 3.2.0
-
Component/s: iOS
-
Labels:
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
- mentioned in
-
Wiki Page Loading...