์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
- nlp
- ๋ฆฌ์กํธ
- native
- ๋ถ์
- react
- ํ์ดํ๋
- cs231n
- linearalgebra
- ๋ฐฑ์ค
- c++
- ๋ฅ๋ฌ๋
- ๋ฐ์ดํฐ์๊ฐํ
- ์ ํ๋์ํ
- ์๋๋ก์ด๋์คํ๋์ค
- Git
- ๊ฒฐ์ ํธ๋ฆฌ
- ๋ค์ดํฐ๋ธ
- Titanic
- ํ๊ตญ์ด์๋ฒ ๋ฉ
- ๋จธ์ ๋ฌ๋
- ๋์
- ์๊ณ ๋ฆฌ์ฆ
- Kaggle
- ๋ฐ์ดํฐ
- ์ธํ๋ฐ
- ๊นํ
- AI
- ์ํ์ฝ๋ฉ
- ๋ฐ์ดํฐ๋ถ์
- ์๋ฒ ๋ฉ
- Today
- Total
yeon's ๐ฉ๐ป๐ป
[React-Native] Tab | Style ์ค์ ๋ณธ๋ฌธ
*
<Drawer.Navigator>๊ณผ ๋ง์ฐฌ๊ฐ์ง๋ก <Tab.Navigator>๋ ๊ฐ ์คํฌ๋ฆฐ์ component์ ๊ฐ๋ณ styling์ ํ์ง ์๋๋ค.
-> ๋ชจ๋ ๊ณตํต์ ์ธ ์คํ์ผ ์ ์ฉํจ
-> <Navigator> ํ๊ทธ ์์ ์์ฑ
-> <Tab.Navigator>์ ์ต์ ์ ์ฃผ์
<Tab.Navigator
initialRouteName="Home"
tabBarOptions={{
activeBackgroundColor: 'skyblue',
activeTintColor: 'blue',
inactiveTintColor: '#fff',
style: {
backgroundColor: '#c6cbef'
}
}}
>
- activeBackgroundColor / activeTintColor : ์ ํ๋์์ ๋ ๋ฐฐ๊ฒฝ์๊ณผ ๊ธ์จ์
- inactiveTintColor : ์ ํ๋์ด์ง์ง ์์ ๊ธ์์
- ์คํฌ๋ฆฐ์ ํ๋ ์ถ๊ฐํด๋ณด์
- message_tab.js๋ผ๋ ํ์ผ ์์ฑ
import TabMessageScreen from './src/message_tab';
...
<Tab.Screen name="Message" component={TabUserScreen}/>
- ๊ฐ ํญ์ (text ๋์ ) ๊ทธ๋ฆผ์ ์ฝ์ ํด๋ณด์
- ๊ทธ๋ฆผ์ ์ฝ์ ํจ๊ณผ ๋์์ ์ ํ๋ ํญ์ ๊ทธ๋ฆผ์ ์ข ๋ ํฌ๊ฒ ๋ง๋๋ ํจ๊ณผ ์ฃผ๊ธฐ
screenOptions={({route})=>({
tabBarLabel: route.name,
tabBarIcon: ({focused})=>(
TabBarIcon(focused, route.name)
)
})}
- ๋จผ์ ์ด๋ค ํญ์ด ์ ํ๋์๋์ง ์์์ผ ํ๋ค.
- route.name : <Tab.Screen>์์์ name์ ์ ์๋ string ๊ฐ
- focused -> Boolean๊ฐ : ํฐ์น๋ ๊ฒ์ธ์ง, active ์ํ์ธ์ง ํ๋ณํ๋ ๋ณ์
- ๊ทธ๋ผ ์ด์ ์๋จ์ TabBarIcon ํจ์๋ฅผ ์์ฑํด๋ณด์
const TabBarIcon = (focused, name) => {
let iconImagePath;
if (name==='Home') {
iconImagePath = require('./src/assets/pics/home_icon.png')
} else if (name==='User') {
iconImagePath = require('./src/assets/pics/user.png')
} else if (name==='Message') {
iconImagePath = require('./src/assets/pics/message.png')
}
return (
<Image
style={{
width: focused? 24 : 20,
height: focused? 24 : 20,
}}
source = {iconImagePath}
/>
)
}
- ์ด๋ฏธ์ง ๋งํฌ๋ฅผ ๋ถ๋ฌ์ฌ ๋๋ require()๋ฅผ ์ด๋ค.
- focused๊ฐ ๋๋ฉด ํฌ๊ธฐ๊ฐ ์ปค์ง๋๋ก ํจ์ ์์ฑ
- ์ ํํ๋ฉด ์์ด์ฝ ํฌ๊ธฐ๊ฐ ๋ ์ปค์ง๋ค.
labelPosition: 'beside-icon'
- ์๋๋๋ก ํ๋ ค๋ฉด 'below-icon'
'Computer ๐ป > React' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[React-Native] Nesting Navigators(ํ๋ฉด ๊ตฌ์กฐ ์ค๊ณ) 01 (0) | 2021.07.31 |
---|---|
[React-Native] Vector Icons ํ์ฉ (0) | 2021.07.31 |
[React-Native] Tab | ์ค์น ๋ฐ ํ๋ฉด Linking (0) | 2021.07.31 |
[React-Native] Drawer | Custom Component (0) | 2021.07.29 |
[React-Native] Drawer | Style ์ค์ 02 (0) | 2021.07.29 |