Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions PickaView/Views/Home/Home.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</connections>
</searchBar>
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="DdB-0f-Tho">
<rect key="frame" x="0.0" y="270" width="393" height="582"/>
<rect key="frame" x="0.0" y="270" width="393" height="465"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="10" minimumInteritemSpacing="10" id="B8z-bL-yo4">
<size key="itemSize" width="392" height="287"/>
Expand Down Expand Up @@ -110,7 +110,7 @@
<constraints>
<constraint firstItem="rM4-xC-Jut" firstAttribute="trailing" secondItem="TIZ-io-mjc" secondAttribute="trailing" id="9eK-me-5id"/>
<constraint firstItem="rM4-xC-Jut" firstAttribute="top" secondItem="TIZ-io-mjc" secondAttribute="top" id="CRs-pA-ERN"/>
<constraint firstAttribute="bottom" secondItem="DdB-0f-Tho" secondAttribute="bottom" id="ape-NJ-Ni8"/>
<constraint firstItem="TIZ-io-mjc" firstAttribute="bottom" secondItem="DdB-0f-Tho" secondAttribute="bottom" id="ape-NJ-Ni8"/>
<constraint firstItem="rM4-xC-Jut" firstAttribute="leading" secondItem="TIZ-io-mjc" secondAttribute="leading" id="cNA-Ks-Iu0"/>
<constraint firstItem="DdB-0f-Tho" firstAttribute="trailing" secondItem="TIZ-io-mjc" secondAttribute="trailing" id="gHu-Zh-224"/>
<constraint firstItem="DdB-0f-Tho" firstAttribute="leading" secondItem="TIZ-io-mjc" secondAttribute="leading" id="tB7-wQ-zG7"/>
Expand Down Expand Up @@ -151,7 +151,7 @@
<resources>
<image name="house.fill" catalog="system" width="128" height="104"/>
<systemColor name="quaternaryLabelColor">
<color red="0.23529411759999999" green="0.23529411759999999" blue="0.26274509800000001" alpha="0.1764705882" colorSpace="custom" customColorSpace="sRGB"/>
<color red="0.23529411764705882" green="0.23529411764705882" blue="0.2627450980392157" alpha="0.17647058823529413" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
Expand Down
11 changes: 7 additions & 4 deletions PickaView/Views/Home/HomeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class HomeViewController: UIViewController {
// 셀 크기 설정
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {

//현재 컬렉션 뷰 크기
let width = collectionView.bounds.width
let height = collectionView.bounds.height

Expand All @@ -104,14 +105,16 @@ class HomeViewController: UIViewController {
insets = isLandscape ? 10 : 0 // 아이폰 세로는 화면 꽉차게 설정
}

let spacing: CGFloat = 10
let spacingBetweenViews: CGFloat = 6.33
let spacing: CGFloat = 10 // 셀 간 간격
let totalSpacing = spacing * (itemsPerRow - 1) + insets * 2
let itemWidth = (width - totalSpacing) / itemsPerRow
let itemWidth = (width - totalSpacing) / itemsPerRow //한 줄에 몇개의 셀을 배치할지에 따라 셀의 너비 계산

let thumbnailHeight = itemWidth * 9 / 16
let extraHeight: CGFloat = 80 //수정 필요
let userImageHeight = itemWidth / 5 // 유저 이미지높이는 전체 셀 너비의 20퍼센트로 설정
let totalHeight = thumbnailHeight + userImageHeight + spacingBetweenViews

return CGSize(width: itemWidth, height: thumbnailHeight + extraHeight)
return CGSize(width: itemWidth, height: totalHeight)
Comment on lines +114 to +117
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

혹시 totalHeigh 이걸 계산 안하고 height에 let height = collectionView.bounds.height 이 height를 주는 방법은 실패하셨나요? 지금도 유동적으로 잘 보이긴하는데, 높이는 자동으로 계산되도록하고 height를 주는게 일반적인 것 같아서용

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UICollectionViewFlowLayout.automaticSize 이걸 쓰면 자동계산이 되지만 아이패드 가로 세로 모드일때 뷰가 깨 질 수 있다고하네요

}

//줄 간격
Expand Down