์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
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 |
- ๋ฐฑ์ค
- ๋ค์ดํฐ๋ธ
- ๊ฒฐ์ ํธ๋ฆฌ
- linearalgebra
- ๋ฐ์ดํฐ์๊ฐํ
- ์ ํ๋์ํ
- Git
- ์๋๋ก์ด๋์คํ๋์ค
- cs231n
- ๋ฅ๋ฌ๋
- ๋ถ์
- ๋จธ์ ๋ฌ๋
- ์ธํ๋ฐ
- c++
- react
- nlp
- ํ๊ตญ์ด์๋ฒ ๋ฉ
- ๋์
- AI
- Kaggle
- native
- ๋ฐ์ดํฐ
- Titanic
- ํ์ดํ๋
- ์๋ฒ ๋ฉ
- ์ํ์ฝ๋ฉ
- ์๊ณ ๋ฆฌ์ฆ
- ๋ฆฌ์กํธ
- ๊นํ
- ๋ฐ์ดํฐ๋ถ์
- Today
- Total
yeon's ๐ฉ๐ป๐ป
[React-Native] Stack | Header Bar ์ค์ ๋ณธ๋ฌธ
- ์ง๊ธ๊น์ง๋ Button์ ๋๋ฅด๋ฉด์ parameter ๊ฐ์ passing ํด์ฃผ์๋ค.
- ๊ทธ๋ฐ๋ฐ ๊ฐ ๋ฃจํธ ์์ฑ ์์ parameter์ ์ด๊ธฐํํ ์๋ ์๋ค!
<Stack.Screen name="Home" component={HomeScreen}/>
<Stack.Screen
name="User"
component={UserScreen}
initialParams = {{
userIdx: 50,
userName: 'Gildong',
userLastName: 'Go'
}}
/>
- App.js์ parameter์ ์ค์ (์ด๊ธฐํ)ํ์
- ์ฒ์ ํ๋ฉด์๋ App.js์์ ์ด๊ธฐํ ํ ๊ฐ์ผ๋ก ์ค์ ๋์ด์๋๋ฐ
- ๋ฒํผ์ ๋๋ฌ ๋์๊ฐ๋ฉด ๊ฐ js์ ์ ๋ ฅํ ๊ฐ์ผ๋ก ๋ฐ๋์ด ์๋ ๊ฒ์ ๋ณผ ์ ์๋ค.
-> StackScreen ์์ฑ ์์ ๋ฃจํธ์ parameter ๊ฐ๋ค์ ์ด๊ธฐํํ ์ ์๊ตฌ๋!
- Header Bar์ ์ด๋ฆ์ ๋ฐ๊ฟ๋ณด์
- default๋ก name์ ์ ์ธํ ๊ฐ์ด ์ถ๋ ฅ๋๊ณ ์๋ค.
<Stack.Navigator initialRouteName="User">
<Stack.Screen
name="Home"
...
options={{title: 'Home Screen'}}
/>
<Stack.Screen
name="User"
...
}}
options={{title: 'User Screen'}}
/>
</Stack.Navigator>
- options์ด๋ผ๋ property ์์ title ๊ฐ์ ์ค๋ค.
- title์ด ๋ฐ๋ ๊ฒ์ ํ์ธํ ์ ์๋ค.
- ์ด๊ธฐ๊ฐ์ผ๋ก ์ค์ ํ์ง ๋ง๊ณ ๋ ์์๋ก ์กฐ์ ๊ฐ๋ฅํ ๊น?
<Button
title="Change the title"
onPress={()=>
this.props.navigation.setOptions({title: 'Changed!!!!'})
}
/>
- ๋ฒํผ์ ๋๋ฅด๋ฉด Header Bar ๊ฐ์ ๋ฐ๊พธ๋๋ก !
- 'Change the title' ๋ฒํผ์ ๋๋ฅด๋ฉด Header Bar๊ฐ ๋ณ๊ฒฝ๋ ๊ฒ์ ๋ณผ ์ ์๋ค.
- ๋ค๋ฅธ option๋ค๋ ์ค์ ํด๋ณด์
<Button
title="Change the title"
onPress={()=>
this.props.navigation.setOptions({
title: 'Changed!!!!',
headerStyle: {
backgroundColor: 'pink'
},
headerTintColor: 'red'
})
}
/>
- headerStyle๊ณผ headerTintColor ์ฃผ๊ธฐ
options={{
title: 'User Screen',
headerStyle: {
backgroundColor: 'pink'
},
headerTintColor: 'red',
headerTitleStyle: {
fontWeight: 'bold',
color: 'purple'
}
}}
- headerTintColor : 'red'
- color : 'purple'
-> ๋์ ์ฐจ์ด ํ์ธํ๊ธฐ
- but, Stack Screen์ด ๊ต์ฅํ ๋ง๋ค๋ฉด App.js์์ ๋ชจ๋ ํ์ผ์ ๋ํ option ์ค์ ์ ํ๋ค๋ ๊ฒ์ ๊ต์ฅํ ๋ถํธํ ์ผ
-> ๊ฐ screen์ ๊ตฌ์ฑํ๋ jsํ์ผ์์ ์ค์ ๊ฐ๋ฅํ๋ค.
- ์์์ ๋ง๋ App.js์ options๋ค์ ๋ชจ๋ ์ฃผ์์ฒ๋ฆฌ ํด์ฃผ๊ณ ,
headerStyle = () => {
this.props.navigation.setOptions({
title: 'Customizing',
headerStyle: {
backgroundColor: 'blue'
},
headerTintColor: 'yellow',
headerTitleStyle: {
fontWeight: 'bold',
color: 'green'
}
})
}
- ์ํ๋ js์์ ์ด๋ ๊ฒ ์ค์ ํ ์ ์๋ค.
- but, ์ฌ๊ธฐ์๋ ๋ง์ฝ ๋ชจ๋ ํ๋ฉด์์์ header bar ์คํ์ผ์ ๋์ผํ๊ฒ ํ๊ณ ์ถ๋ค๋ฉด
์ผ์ผ์ด ๊ฐ๊ฐ์ screen์์ option ์ค์ ํ๋ ๊ฒ์ ๋ ๋นํจ์จ์ ์ผ ๊ฒ
-> ๊ณตํต์ ์ผ๋ก ๋ณ๊ฒฝํ๋ ๋ฐฉ๋ฒ์? ๋ค์ ์๊ฐ์ !
'Computer ๐ป > React' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[React-Native] Stack | Header Bar ์ปค์คํฐ๋ง์ด์ง & ๋ฒํผ ์ถ๊ฐ (0) | 2021.07.28 |
---|---|
[React-Native] Stack | ์ฌ๋ฌ ํ๋ฉด์ ๊ณตํต Style ์ ์ฉ (0) | 2021.07.28 |
[React-Native] Stack | Navigation Params (0) | 2021.07.27 |
[React-Native] React Navigation | ํ๋ฉด Linking 01 (0) | 2021.07.24 |
[React-Native] React Navigation ์ค์น (0) | 2021.07.24 |