TouchableOpacity

React 实战教程 深入学习一线大厂必备前端技能,VIP 教程限时免费领取。 立即查看 >

If you're looking for a more extensive and future-proof way to handle touch-based input, check out the Pressable API.

本组件用于封装视图,使其可以正确响应触摸操作。当按下的时候,封装的视图的不透明度会降低。

不透明度的变化是通过把子元素封装在一个Animated.View中来实现的,这个动画视图会被添加到视图层级中,少数情况下有可能会影响到布局。(译注:此组件与 TouchableHighlight 的区别在于并没有额外的颜色变化,更适于一般场景。)

示例#


文档#

Props#

Inherits TouchableWithoutFeedback Props.

style#

类型必需
View.style

activeOpacity#

指定封装的视图在被触摸操作激活时以多少不透明度显示(0 到 1 之间)。默认值为 0.2。

类型必需
number

tvParallaxProperties#

(Apple TV only) Object with properties to control Apple TV parallax effects.

  • enabled: If true, parallax effects are enabled. Defaults to true.
  • shiftDistanceX: Defaults to 2.0.
  • shiftDistanceY: Defaults to 2.0.
  • tiltAngle: Defaults to 0.05.
  • magnification: Defaults to 1.0.
  • pressMagnification: Defaults to 1.0.
  • pressDuration: Defaults to 0.3.
  • pressDelay: Defaults to 0.0.
类型必需平台
objectiOS

hasTVPreferredFocus#

(Apple TV only) TV preferred focus (see documentation for the View component).

类型必需平台
booliOS

nextFocusDown#

TV next focus down (see documentation for the View component).

类型Required平台
boolNoAndroid

nextFocusForward#

TV next focus forward (see documentation for the View component).

类型Required平台
boolNoAndroid

nextFocusLeft#

TV next focus left (see documentation for the View component).

类型Required平台
boolNoAndroid

nextFocusRight#

TV next focus right (see documentation for the View component).

类型Required平台
boolNoAndroid

nextFocusUp#

TV next focus up (see documentation for the View component).

类型Required平台
boolNoAndroid