Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

添加屏幕适配相关的代码与第三方库。 #12

Open
zgatrying opened this issue Nov 16, 2018 · 2 comments
Open

添加屏幕适配相关的代码与第三方库。 #12

zgatrying opened this issue Nov 16, 2018 · 2 comments
Milestone

Comments

@zgatrying
Copy link
Owner

zgatrying commented Nov 16, 2018

适配设备安全区域的第三方库react-native-safearea-view

安装依赖

yarn add react-native-safe-area-view

使用

import SafeAreaView from 'react-native-safe-area-view'

<SafeAreaView>
{//...}
</SafeAreaView>
@zgatrying
Copy link
Owner Author

zgatrying commented Nov 16, 2018

适配设计稿与实际设备设备像素比的方案

  • 根据设备实际像素比转换所有组件在设计稿中的宽高。
  • 根据设备实际像素比对根组件进行缩放,需要使用transform属性的scale值。内部组件使用与设计稿相同的尺寸。

@zgatrying
Copy link
Owner Author

zgatrying commented Nov 28, 2018

ps:React Navigation already includes and uses this view starting in v1.0.0-beta.16.

补充说明:react-navigation库早在v1.0.0-beta.16版本起就使用了该库。因此通过react-navigation构建路由的应用不需要在专门安装这个库。

而且在TabNavigator组件内的Screen不需要考虑适配IPhoneX的底部,而StackNavigator组件内的Screen还是需要考虑适配iPhone X的底部,因此仍然需要手动引入react-native-safe-area-view库,将SafeAreaView组件作为Screen组件的根组件。

@zgatrying zgatrying added this to the v0.1.0 milestone Nov 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant