React-native: tvOS How to force a Button to be foc

2019-08-13 00:51发布

It is possible to force a button to be focused ? I know the user can focused an element but I want to make it programmatically

1条回答
我命由我不由天
2楼-- · 2019-08-13 01:33

Yes it is possible, with tvOS and react native if you want to force a focusable component to be focus you just need to set hasTVPreferredFocus to true

For example:

<TouchableHighlight
    hasTVPreferredFocus={true}
    onPress={() => {}}
>
    <Text>Hello</Text>
</TouchableHighlight>
查看更多
登录 后发表回答