https://github.com/hyun99999/verticalcardswipertutorial-ios
π VerticalcardswiperTutorial
https://github.com/hyun99999/verticalcardswipertutorial-ios
ios openlibrary
Last synced: 2 months ago
JSON representation
π VerticalcardswiperTutorial
- Host: GitHub
- URL: https://github.com/hyun99999/verticalcardswipertutorial-ios
- Owner: hyun99999
- Created: 2021-08-04T14:58:17.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-08-20T13:44:37.000Z (almost 4 years ago)
- Last Synced: 2025-01-25T15:31:51.260Z (4 months ago)
- Topics: ios, openlibrary
- Language: Swift
- Homepage:
- Size: 8.9 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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 VerticalCardSwiperclass 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 VerticalCardSwiperclass VerticalCardSwiperCell: CardCell {
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
}
```- VerticalCardSwiperCell.xib
λ€μκ³Ό κ°μ΄ κ½μ°¨λλ‘ uiview λ₯Ό λ§λ€μκ³ card λ₯Ό ꡬλΆν μ μλλ‘ background color λ₯Ό μ€μ ν΄λ³΄μλ€.
### Result
μ μ μ©μ΄ λμλ€.
### μ΅λν νλμΉ΄λ DIVE μ±μ ν΄λ‘ ν΄λ³΄μ
![]()