Modal
模态框组件是用来在封闭视图之上呈现内容的基本方式。
示例
参考
属性
视图属性
继承视图属性。
animated
已弃用。请使用
animationType
属性代替。
animationType
animationType
属性控制模态框的动画方式。
可能的值
slide
从底部滑入fade
淡入视图none
无动画显示
类型 | 默认值 |
---|---|
enum('none' , 'slide' , 'fade' ) | none |
backdropColor
模态框的backdropColor
(或模态框容器的背景颜色)。如果未提供且transparent
为false
,则默认为white
。如果transparent
为true
,则忽略此属性。
类型 | 默认值 |
---|---|
color | white |
hardwareAccelerated
Android
hardwareAccelerated
属性控制是否强制对底层窗口进行硬件加速。
类型 | 默认值 |
---|---|
bool | false |
navigationBarTranslucent
Android
navigationBarTranslucent
属性决定模态框是否应该在系统导航栏下方显示。但是,statusBarTranslucent
也需要设置为true
才能使导航栏半透明。
类型 | 默认值 |
---|---|
bool | false |
onDismiss
iOS
onDismiss
属性允许传入一个函数,该函数将在模态框被关闭后调用。
类型 |
---|
function |
onOrientationChange
iOS
当模态框显示时方向发生变化时,将调用onOrientationChange
回调。提供的方向仅为“portrait”或“landscape”。无论当前方向如何,此回调也会在初始渲染时调用。
类型 |
---|
function |
onRequestClose
当用户点击 Android 上的硬件返回按钮或 Apple TV 上的菜单按钮时,将调用onRequestClose
回调。由于此属性是必需的,请注意,只要模态框处于打开状态,就不会触发BackHandler
事件。在 iOS 上,当presentationStyle
为pageSheet
或formSheet
时,此回调会在模态框通过拖动手势关闭时调用。
类型 |
---|
function 必需 Android TV function iOS |
onShow
onShow
属性允许传入一个函数,该函数将在模态框显示后调用。
类型 |
---|
function |
presentationStyle
iOS
presentationStyle
属性控制模态框的显示方式(通常在 iPad 或 Plus 尺寸 iPhone 等较大设备上)。详见https://developer.apple.com/reference/uikit/uimodalpresentationstyle。
可能的值
fullScreen
完全覆盖屏幕pageSheet
覆盖居中显示的人像宽度视图(仅限较大设备)formSheet
覆盖居中显示的窄宽度视图(仅限较大设备)overFullScreen
完全覆盖屏幕,但允许透明
类型 | 默认值 |
---|---|
enum('fullScreen' , 'pageSheet' , 'formSheet' , 'overFullScreen' ) | 如果transparent={false} 则为fullScreen 如果 transparent={true} 则为overFullScreen |
statusBarTranslucent
Android
statusBarTranslucent
属性决定模态框是否应该在系统状态栏下方显示。
类型 | 默认值 |
---|---|
bool | false |
supportedOrientations
iOS
supportedOrientations
属性允许模态框旋转到任何指定的方向。在 iOS 上,模态框仍受限于应用 Info.plist 中 UISupportedInterfaceOrientations 字段的设置。
当使用
pageSheet
或formSheet
的presentationStyle
时,iOS 将忽略此属性。
类型 | 默认值 |
---|---|
array of enums('portrait' , 'portrait-upside-down' , 'landscape' , 'landscape-left' , 'landscape-right' ) | ['portrait'] |
transparent
transparent
属性决定模态框是否会填充整个视图。将其设置为true
将使模态框在透明背景上渲染。
类型 | 默认值 |
---|---|
bool | false |
visible
visible
属性决定模态框是否可见。
类型 | 默认值 |
---|---|
bool | true |