Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UICollectionViewCompositionalLayout 애플 개발자 문서 #158

Closed
Youngminah opened this issue Apr 25, 2022 · 0 comments
Closed

UICollectionViewCompositionalLayout 애플 개발자 문서 #158

Youngminah opened this issue Apr 25, 2022 · 0 comments

Comments

@Youngminah
Copy link
Owner

Youngminah commented Apr 25, 2022

UICollectionViewCompositionalLayout은 정말 개사기 개념!...

  • 이러한 구성을 TableView안에 CollectionView넣고 등등 그럴 필요가 없이
  • 깔끔히 CollectionView 하나❗️만을 이용하여 구성 가능.


UICollectionView

  • 컬렉션 뷰는 컬렉션 뷰의 데이터 소 프로퍼티에 저장된 데이터 소스 객체로부터 데이터를 받아온다.
  • 데이터소스로 UICollectionViewDiffableDataSource 객체를 이용 할 수 있는데,
  • 또한, data source는 UICollectionViewDataSource 프로토콜을 채택하는
  • 데이터 소스를 커스텀으로 만들어서 사용할 수도 있다.


UICollectionViewLayout

  • Supplementary view는 유저에 의해 선택될 수 없음.
  • 해더나 푸터 용으로 사용할 수 있음.
  • 옵셔널이고 굳이 필요없다면 사용 안해도 된다.


UICollectionViewFlowLayout

  • delegate를 제공하지 않으면 default값으로 레이아웃이 잡힘.


UICollectionViewCompositionalLayout

  • compositional layout은 하나 이상의 grouping된 section으로 구성된다.
  • group이라는 개념이 Compositional Layout에 들어감.
  • item, group, section 3가지에 관한 정보를 UICollectionViewCompositionalLayout에 주어야한다.
  • Group에서의
    • widthDimension : .fractionalwidth를 사용시 컬렉션뷰 너비에 대한 비율임. 1이면 동일
    • heightDimension : .fractionalheight를 사용시 컬렉션뷰 높이에 대한 비율임. 1이면 동일
  • item에서의
    • widthDimension : .fractionalwidth를 사용시 그룹 너비에 대한 비율임. 1이면 동일
    • heightDimension : .fractionalheight를 사용시 그룹 높이에 대한 비율임. 1이면 동일
  • Section을 여러개 두고 싶을시 UICollectionViewCompositionalLayout을 생성할 때,
  • 생성자중에 @escaping을 이용한 생성자가 있다.
    • image
  • UICollectionViewCompositionalLayoutSectionProvider라고 typealias를 반환하는데,
typealias UICollectionViewCompositionalLayoutSectionProvider = (Int, NSCollectionLayoutEnvironment) -> NSCollectionLayoutSection? 
  • 형태 이다.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant