[Swift] Custom View 만들기
Custom View를 만드는 방법은 2 가지가 있다.
- Xib
- Swift programmatically code
Xib 파일
Xib란 Xcode Interface Builder의 약자로 Nib 파일을 XML 형식으로 변환한 파일이다.
XML로 이루어져있어서 소스코드를 좀 더 알아보기 편하게 구성되어 있다.
- Nib을 사용하다가 추후에 나오게 된 형식이다.
- Nib : NEXTSTEP Interface Builder의 약자로 바이너리 형식의 파일이다.
- User Interface를 저장하고 처리하는 속도가 빠르다
- Xib파일을 빌드하면 Nib으로 컴파일 되고 그 파일을 배포하는 식이다.
Example
TableView나 CollectionView의 Cell을 Xib파일로 만드는 예시
- 구분하기 쉽도록 같은이름으로 Xib, Swift파일을 만든다.
- CustomView라 SafeArea는 필요없으니 체크박스를 끊다(❓)