스플래쉬(Splash) 화면이란 ? 앱이 구동을 시작할때 켜지기 전 나오는 화면을 말한다.  어플리케이션에서 실행에 필요한 데이터를 불러오는데 이용되며, 브랜드 명칭을 알려주는데도 사용된다. 




1
2
3
4
5
6
7
8
9
10
11
12
13
import Splash from "./src/Splash";
 
 
 
export default class App extends Component {
 
 
  render() {
    return (
      <Splash />
    );
  }
}

cs

[App.js]

Splash.js 파일을 생성하고 render 함수에 return 값으로 호출한다.



1
2
3
4
5
6
7
8
9
10
render() {
    return (
      <View style ={styles.container}>
        <Text style={styles.title}> Hello World !!!! </Text>
        <Text style={styles.subtitle}> Powered by React Native </Text>
      </View>  
      
    );
  }
 
cs

View컴포넌트 내부에 Text 컴포넌트 두개를 배치했을때의 화면구성이다.

1
2
3
4
5
6
7
8
 <View style ={styles.container}>
        <View style={style.titleContainer}>
            <Text style={styles.title}> Hello World !!!! </Text>
        </View>
        <View>
            <Text style={styles.subtitle}> Powered by React Native </Text>
        </View>
      </View>

cs

Text 컴포넌트를 View 컴포넌트로 각각 감싸고 titleContainer영역을 따로 지정한뒤 , backGroundColor 속성을 다르게 지정하여 레이아웃구성을 잡아준다.


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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import React, { Component } from 'react';
import { View, Text , StyleSheet } from 'react-native';
 
export default class Splash extends Component {
  constructor(props) {
    super(props);
    this.state = {
    };
  }
 
  render() {
    return (
      <View style ={styles.container}>
        <View style={styles.titleContainer}>
            <Text style={styles.title}> Hello World !!!! </Text>
        </View>
        <View>
            <Text style={styles.subtitle}> Powered by React Native </Text>
        </View>
      </View>
    );
  }
}
 
 
 
const styles = StyleSheet.create({
    
    container: { 
        // backgroundColor: 'red', 
        backgroundColor : '#3498db',
        flex: 1
        justifyContent: "center"
        alignItems: "center"  
    },
    title : {
        color : 'white',
        fontSize: 35,
        fontWeight: 'bold'
    },
    subtitle : {
        color : 'white',
        fontWeight: '200'
    }, titleContainer : {
        justifyContent : 'center',
        flex : 1
    }
});

cs

[Splash.js]

완성된 Splash 화면인데, 해당화면을 좀 수정해서 Weather App 스플래쉬화면으로 변경할 예정이다. 


백그라운드컬러피커 참고 




블로그 이미지

클라인STR

,