반응형
ReactNative로 개발을 하다보면 특히 화면을 구성할 때 iOS, Android를 구분해서 다르게 구성하는 경우도 있습니다.
이럴 때 iOS인지 Android인지 구분하는 방법을 알아보겠습니다.
import React from 'react';
import {Platform, SafeAreaView, StyleSheet} from 'react-native';
const App = {
return (
<>
<SafeAreaView style={styles.container}>
</SafeAreaView>
</>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
padding: Platform.select({ios: 10, android: 20})
}
});
export default App;
Platform을 사용하면 운영체제별 다른 값으로 설정하여 운영체제에 따라서 다르게 표시되거나 혹은 이상하게 등등의 현상을 해결할 수 있습니다.
반응형
'Programming > React Native' 카테고리의 다른 글
[ReactNative] CocoaPods could not find compatible versions for pod "RCT-Folly": (466) | 2023.04.21 |
---|---|
[ReactNative] CodePush (0) | 2021.08.04 |
[ReactNative] axios사용하면서 release버전에서 에러 날 경우 (0) | 2021.08.04 |
[ReaceNative] Expiring Daemon because JVM heap space is exhausted (0) | 2021.08.04 |
[ReactNative] CodePush 셋팅 (0) | 2021.08.03 |