## ๐ง ๋ฌธ์ ์ ํด๊ฒฐ ### M1 CocoaPod ์ค์น ๋ฌธ์ -> iTerm ์ ๋ณด ๊ฐ์ ธ์ค๊ธฐ > `Rosetta๋ฅผ ์ฌ์ฉํ์ฌ ์ด๊ธฐ` ์ฒดํฌ -> `brew install cocoapods` or `sudo gem install cocoapods` -> `sudo arch -x86_64 gem install ffi` -> Podfile์ด ์๋ ํ๋ก์ ํธ directory์์ ํฐ๋ฏธ๋ ์ฐ ํ, `arch -x86_64 pod install` --- ### CollectionView ์คํ ๋ ์ด์์ ์๋ฌ **๋ฌธ์ ** ```swift= let itemSize = NSCollectionLayoutSize( widthDimension: NSCollectionLayoutDimension.fractionalWidth(1), heightDimension: .estimated(40) // ๋ฌธ์ ์ ์์ธ ) ``` - `NSCollectionLayoutDimension.estimated(40)` ์ฝ๋๊ฐ ๊ธฐ๋ณธ ๋์ด ๊ฐ์ ์๋ฏธํ๋ค๊ณ ์๊ฐํ๊ณ ์ค์ View ์ ํฌ๊ธฐ์ ๋ฐ๋ผ ๊ฐ๋ณ์ ์ผ๋ก ๋ณํํ ๊ฒ์ผ๋ก ๊ธฐ๋ํจ - Cell ์ ๋์ด๋ฅผ 130dp ๋ก ์ค์ ํ๊ธฐ ์ํด Cell ์ ํ์ View ์ `HeightAnchor` ๋ฅผ 130 ์ผ๋ก ๊ณ ์ **ํด๊ฒฐ** - `NSCollectionLayoutDimension.estimated(40)` ๋ณด๋ค ์ค์ ์ฌ์ด์ฆ๊ฐ ๋ ํฌ๋ฉด AutoLayout ์๋ฌ๋ฅผ ๋ฐ์ํ๋ ๊ฒ์ ๋ฐ๊ฒฌํจ - ์ค์ ์ฌ์ด์ฆ๊ฐ estimated ์ฌ์ด์ฆ ๋ฒ์ ์ด๋ด์ด๋ฉด ์ค์ View ์ ํฌ๊ธฐ๋ก ํ๋ฉด์ ํ์๋๋ ๊ฒ์ ์๊ฒ ๋จ **์๋** 1. `NSCollectionLayoutDimension.estimated(40)` ์ผ๋ก ์ค์ ํ๊ณ Cell ์ Image View ์ `HeightAnchor` ๋ฅผ `greaterThanEqualTo` ๋ก ์ค์ ํ๋ AutuLayout ์๋ฌ๊ฐ ์ฌ๋ผ์ง๊ณ ์ํ๋ ๊ฒฐ๊ณผ๋ฅผ ์ป์. ๊ทธ๋ฌ๋ ImageView ์ image ์ ์ค์ ํฌ๊ธฐ์ ์ํฅ์ ๋ฐ์ ์ค์ Cell ์ ํฌ๊ธฐ๋ 130 ๋ณด๋ค ์ปค์ง - `EqualTo` ์ต์ ์ฌ์ฉ ์ estimated ๊ฐ ์ดํ์ฌ์ผ ์๋ฌ๊ฐ ๋ฐ์๋์ง ์๋๋ค. - `greaterThanEqualTo` ์ฌ์ฉ ์ estimated ๊ฐ์ ์ด๊ณผํ ์ ์๋ค. 3. 1. ์ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๊ธฐ ์ํด estimated ๊ฐ์ 130์ผ๋ก ๋ณ๊ฒฝํ๊ณ Image View ์ `HeightAnchor` ๋ฅผ `greaterThanEqualTo` ์์ `EqualTo` ๋ก ๋ณ๊ฒฝ --- ### CollectionViewCell Register ์ํด์ ํ๋ฉด์ด ์๋์ด๊ฐ **๋ฌธ์ ** - ์คํ ๋ฆฌ๋ณด๋์์ cell์ ๋ง๋ค๊ณ identifier๋ฅผ ์ง์ ํด์ค์ ๋ฐ๋ก register๋ฅผ ํด์ฃผ์ง ์์ - cell์ ํด๋ฆญ ํ์ ๋, `didSelectItemAt:` ํจ์๊ฐ ๋ถ๋ฆฌ์ง ์์ **ํด๊ฒฐ** ```swift= collectionView.register(ProductDetailCell.self, forCellWithReuseIdentifier: ProductDetailCell.identifier) ``` - view controller์์ cell์ ๊ฐ์ ์ด๋ฆ์ผ๋ก register ํด์ฃผ๋ ๊ฒ์ผ๋ก ํด๊ฒฐ --- ### Badge ๊ฐ์์ ๋ฐ๋ฅธ ํฌ๊ธฐ ์กฐ์ ```swift self.adjustsFontSizeToFitWidth = true self.minimumScaleFactor = 0.5 ``` - ๊ณต๊ฐ์ด ๋ถ์กฑํ๋ฉด ํฐํธ์ ์ฌ์ด์ฆ๋ฅผ 0.5๋ฐฐ๊น์ง ์ค์ผ ์ ์๋๋ก ์์ ํ์ฌ ํด๊ฒฐ -> ์ฌ์ ํ badge๊ฐ ๋๋ฌด ๋ง์์ง๊ฑฐ๋ ํ๋ฉด์ด ์์์ง๋ฉด ํฐํธ๊ฐ ์๋ฆฌ๋ ๋ฌธ์ ๊ฐ ๋จ์์์
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up