入门
开发指南
- 模块
- 控件基础知识
- 控件树
- 选择器 API
- 布局
- 手势和触摸事件
- W3C APIs 兼容
- Cordova 插件支持
- EcmaScript 6,TypeScript 和 JSX
- Windows 10 支持说明
- 构建 Tabris.js App
- Tabris.js App 补丁
API 参考文档
- app
- device
- fs
- localStorage
- ui
- ActionSheet(操作列表)
- AlertDialog(对话框)
- CanvasContext
- InactivityTimer(闲置定时器)
- NativeObject
- Popup(弹出窗)
- Timer(计时器)
- WidgetCollection
控件
- Action
- ActivityIndicator
- Button
- Canvas
- CheckBox
- CollectionView
- Composite
- Drawer
- ImageView
- NavigationBar
- NavigationView
- Page
- Picker
- ProgressBar
- RadioButton
- ScrollView
- SearchAction
- Slider
- StatusBar
- Switch
- Tab
- TabFolder
- TextInput
- TextView
- ToggleButton
- Video
- WebView
- Widget
自定义控件
StatusBar
Extends Widget
The status bar is the area where notifications, status icons and device time are displayed. The singleton instance can be accessed via ui.statusBar
.
Import this type with “const {StatusBar} = require('tabris');
”
Properties
background
Type: Color
Background color of the status bar. Should be used in conjunction with the theme
property to keep the status bar icons legible.
displayMode
Type: string, supported values: default
, hide
, float
, default: default
Controls how the status bar is positioned relative to the ui.contentView
. The value default
places the content below the status bar. The hide
option lets the status bar disappear, making more room for the content. The float
option lets the content flow underneath the status bar. On Windows float
is currently not supported and treated as hide
.
height
read-only
Type: number
The height of the status bar in device independent pixel. Can be used in conjunction with the displayMode
'float'
to offset the content as to not have it covered by the status bar.
This property can only be set on widget creation. Once set, it cannot be changed anymore.
theme
iOSAndroid
Type: string, supported values: default
, light
, dark
, default: default
Defines the shade used on the status bar. A dark
theme sets the foreground icons to be of a light color, whereas light
sets the icons to a dark color. The theme should be set in conjunction with the background
property for contrast. The value default
selects the default theme that depends on the device and on the app. Available on iOS and Android 6+.
Events
backgroundChanged
Fired when the background property has changed.
Event Parameters
target: this The widget the event was fired on.
value: Color The new value of background.
displayModeChanged
Fired when the displayMode property has changed.
Event Parameters
target: this The widget the event was fired on.
value: string The new value of displayMode.
themeChanged
Fired when the theme property has changed.
Event Parameters
target: this The widget the event was fired on.
value: string The new value of theme.
Example
const {Picker, TextView, ui} = require('tabris');
const THEMES = ['default', 'light', 'dark'];
const DISPLAY_MODES = ['default', 'float', 'hide'];
const BACKGROUNDS = [ui.statusBar.background, 'rgba(0, 0, 0, 0.25)', 'red', 'green', 'blue'];
createTextView('Theme', 'theme');
createTextView('Display mode', 'displayMode');
createTextView('Background', 'background');
createTextView('Height', 'height');
new Picker({
left: '#displayMode 16', baseline: '#theme', right: 16,
itemCount: THEMES.length,
itemText: index => THEMES[index]
}).on('select', ({index}) => ui.statusBar.theme = THEMES[index])
.appendTo(ui.contentView);
new Picker({
left: '#displayMode 16', baseline: '#displayMode', right: 16,
itemCount: DISPLAY_MODES.length,
itemText: index => DISPLAY_MODES[index]
}).on('select', ({index}) => ui.statusBar.displayMode = DISPLAY_MODES[index])
.appendTo(ui.contentView);
new Picker({
left: '#displayMode 16', baseline: '#background', right: 16,
itemCount: BACKGROUNDS.length,
itemText: index => BACKGROUNDS[index]
}).on('select', ({index}) => ui.statusBar.background = BACKGROUNDS[index])
.appendTo(ui.contentView);
new TextView({
left: '#displayMode 16', baseline: '#height', right: 16,
text: ui.statusBar.height
}).appendTo(ui.contentView);
function createTextView(text, id) {
new TextView({
id: id,
left: 16, top: 'prev() 16',
text: text
}).appendTo(ui.contentView);
}
See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论