An open API service indexing awesome lists of open source software.

https://github.com/hyun99999/verticalcardswipertutorial-ios

πŸ“‡ VerticalcardswiperTutorial
https://github.com/hyun99999/verticalcardswipertutorial-ios

ios openlibrary

Last synced: 2 months ago
JSON representation

πŸ“‡ VerticalcardswiperTutorial

Awesome Lists containing this project

README

        

πŸ“‡ VerticalcardswiperTutorial
---

VerticalCardSwiper μ˜€ν”ˆλΌμ΄λΈŒλŸ¬λ¦¬λ₯Ό μ•Œμ•„λ³΄μž
μ΅œκ·Όμ— ν˜„λŒ€μΉ΄λ“œ DIVE λΌλŠ” μ•±μ˜ λ ˆμ΄μ•„μ›ƒμ„ 보고 λ‹€μŒκ³Ό 같은 layout λ₯Ό κ°€μ§€λŠ” μ˜€ν”ˆ λΌμ΄λΈŒλŸ¬λ¦¬κ°€ μ—†λ‚˜μ°Ύμ•„λ³΄μ•˜λ‹€.

[2021.07.29 (λͺ©) - ν˜„λŒ€μΉ΄λ“œ DIVE iOS](https://www.youtube.com/watch?v=B8-cTdaUuRQ)

μ•„λž˜μ˜ μ‚¬μ΄νŠΈκ°€ μ•„μ£Ό μœ μš©ν•˜λ‹€ μΆ”μ²œν•œλ‹€

[iOS Example](https://iosexample.com)

VerticalCardSwiper λΌλŠ” μ˜€ν”ˆ 라이브러리λ₯Ό μ°Ύμ•˜λ‹€.

[GitHub - JoniVR/VerticalCardSwiper: A marriage between the Shazam Discover UI and Tinder, built with UICollectionView in Swift.](https://github.com/JoniVR/VerticalCardSwiper)

### Introduce

이 ν”„λ‘œμ νŠΈμ˜ λͺ©ν‘œλŠ” μΉ΄λ“œλ₯Ό μ™Όμͺ½/였λ₯Έμͺ½μœΌλ‘œ μŠ€μ™€μ΄ν”„ν•˜λŠ” Tinder μŠ€νƒ€μΌκ³Ό κ²°ν•©ν•˜μ—¬ Shazam 의 Discover UI λ₯Ό μž¬ν˜„ν•˜λŠ” 것이라고 ν•œλ‹€. 이것은 UICollectionView 및 custom flowLayout 으둜 λΉŒλ“œλ©λ‹ˆλ‹€.

### Installation

CocoaPods

```swift
pod 'VerticalCardSwiper'
```

### Usage

μš°λ¦¬κ°€ μ‚¬μš©ν•  μ£Όμš”ν•œ ν΄λž˜μŠ€λ“€μ΄ 무엇을 μƒμ†λ°›λŠ”μ§€ λ¨Όμ € ν™•μΈν•΄λ³΄μž

```swift
public class VerticalCardSwiper: UIView {

/// The collectionView where all the magic happens.
public var verticalCardSwiperView: VerticalCardSwiperView!
// ...
```

```swift
public class VerticalCardSwiperView: UICollectionView {
// ...
```

```swift
@objc open class CardCell: UICollectionViewCell {
```

μš°λ¦¬λŠ” λ·°μ»¨νŠΈλ‘€λŸ¬μ—μ„œ VerticalCardSwiper λ₯Ό λ§Œλ“€κ³  μ›ν•˜λŠ” ν¬κΈ°λŒ€λ‘œ 섀정을 ν•  것이닀.

κΉƒν—ˆλΈŒμ—μ„œ μ œκ³΅ν•˜λŠ” μ½”λ“œλ₯Ό 보자

- ViewController.swift

```swift
import VerticalCardSwiper

class ExampleViewController: UIViewController, VerticalCardSwiperDatasource {

private var cardSwiper: VerticalCardSwiper!

override func viewDidLoad() {
super.viewDidLoad()

cardSwiper = VerticalCardSwiper(frame: self.view.bounds)
view.addSubview(cardSwiper)

cardSwiper.datasource = self

// register cardcell for storyboard use
cardSwiper.register(nib: UINib(nibName: "ExampleCell", bundle: nil), forCellWithReuseIdentifier: "ExampleCell")
}

func cardForItemAt(verticalCardSwiperView: VerticalCardSwiperView, cardForItemAt index: Int) -> CardCell {

if let cardCell = verticalCardSwiperView.dequeueReusableCell(withReuseIdentifier: "ExampleCell", for: index) as? ExampleCardCell {
return cardCell
}
return CardCell()
}

func numberOfCards(verticalCardSwiperView: VerticalCardSwiperView) -> Int {
return 100
}
}
```

CardCell λ₯Ό μƒμ†λ°›μ•„μ„œ ExampleCardCell λ₯Ό μ»€μŠ€ν…€ν•  수 μžˆλ‹€.

λ‚˜λŠ” μ’€ 더 νŽΈν•˜κ²Œ μ‚¬μš©ν•΄λ³΄κ³  μ‹Άμ—ˆλ‹€.

λ‹€μŒκ³Ό 같이 λŒ€μ²΄ν–ˆλ‹€

- ViewController.swift

```swift
@IBOutlet weak var cardSwiper: VerticalCardSwiper!
// private var cardSwiper: VerticalCardSwiper!

override func viewDidLoad() {
super.viewDidLoad()
// cardSwiper = VerticalCardSwiper(frame: self.view.bounds)
// view.addSubview(cardSwiper)
cardSwiper.datasource = self
cardSwiper.register(nib: UINib(nibName: "VerticalCardSwiperCell", bundle: nil), forCellWithReuseIdentifier: "VerticalCardSwiperCell")
}
```

- VerticalCardSwiperCell.swift

```swift
import UIKit
import VerticalCardSwiper

class VerticalCardSwiperCell: CardCell {

override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
}
```

- VerticalCardSwiperCell.xib

λ‹€μŒκ³Ό 같이 꽉차도둝 uiview λ₯Ό λ§Œλ“€μ—ˆκ³  card λ₯Ό ꡬ뢄할 수 μžˆλ„λ‘ background color λ₯Ό μ„€μ •ν•΄λ³΄μ•˜λ‹€.

### Result

잘 적용이 λ˜μ—ˆλ‹€.

### μ΅œλŒ€ν•œ ν˜„λŒ€μΉ΄λ“œ DIVE 앱을 ν΄λ‘ ν•΄λ³΄μž