Commit ab61a4b4 authored by Steven杜宇's avatar Steven杜宇

// 卡片动效

parent 4fca4d46
...@@ -87,6 +87,8 @@ target 'galaxy' do ...@@ -87,6 +87,8 @@ target 'galaxy' do
pod 'lottie-ios', '4.4.0' pod 'lottie-ios', '4.4.0'
#GIF图播放 #GIF图播放
pod 'YYImage', '1.0.4' pod 'YYImage', '1.0.4'
#滑动卡片
pod 'DragCardContainer'
end end
......
...@@ -7,11 +7,12 @@ ...@@ -7,11 +7,12 @@
// //
import UIKit import UIKit
import DragCardContainer
class YHMatchPeopleViewController: YHBaseViewController { class YHMatchPeopleViewController: YHBaseViewController {
var matchArr:[String] = ["", "", ""] var matchCardsArr:[String] = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]
lazy var bgImgV:UIImageView = { lazy var bgImgV:UIImageView = {
let bg = UIImageView(image: UIImage(named: "people_match_result_bg")) let bg = UIImageView(image: UIImage(named: "people_match_result_bg"))
...@@ -46,6 +47,39 @@ class YHMatchPeopleViewController: YHBaseViewController { ...@@ -46,6 +47,39 @@ class YHMatchPeopleViewController: YHBaseViewController {
return btn return btn
}() }()
private let allowedDirection: [Direction] = [.left, .up, .right]
lazy var cardContainer: DragCardContainer = {
let cardContainer = DragCardContainer()
// 是否可以无限滑动
cardContainer.infiniteLoop = false
// 数据源
cardContainer.dataSource = self
// 代理
cardContainer.delegate = self
// 可见卡片数量
cardContainer.visibleCount = 3
// 是否可以打印日志
cardContainer.enableLog = true
// 是否禁用卡片拖动
cardContainer.disableTopCardDrag = false
// 是否禁用卡片点击
cardContainer.disableTopCardClick = false
let mode = ScaleMode()
// 卡片之间间距
mode.cardSpacing = 5
// 方向(可以运行Demo,修改该参数看实际效果)
mode.direction = .bottom
// 最小缩放比例
mode.minimumScale = 0.9
// 卡片最大旋转角度
mode.maximumAngle = 0
// 赋值mode
cardContainer.mode = mode
cardContainer.isHidden = true
return cardContainer
}()
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
createUI() createUI()
...@@ -65,8 +99,9 @@ class YHMatchPeopleViewController: YHBaseViewController { ...@@ -65,8 +99,9 @@ class YHMatchPeopleViewController: YHBaseViewController {
let wingRightImgV = UIImageView(image: UIImage(named: "people_match_wing_right")) let wingRightImgV = UIImageView(image: UIImage(named: "people_match_wing_right"))
self.view.addSubview(wingRightImgV) self.view.addSubview(wingRightImgV)
self.view.addSubview(cardContainer)
self.bgImgV.snp.makeConstraints { make in self.bgImgV.snp.makeConstraints { make in
make.edges.equalToSuperview() make.edges.equalToSuperview()
} }
...@@ -104,6 +139,14 @@ class YHMatchPeopleViewController: YHBaseViewController { ...@@ -104,6 +139,14 @@ class YHMatchPeopleViewController: YHBaseViewController {
make.left.equalTo(self.topLabel.snp.right) make.left.equalTo(self.topLabel.snp.right)
make.centerY.equalTo(self.topLabel) make.centerY.equalTo(self.topLabel)
} }
cardContainer.snp.makeConstraints { make in
make.centerX.equalToSuperview()
make.left.equalTo(36)
make.right.equalTo(-36)
make.top.equalToSuperview().offset(102+k_Height_NavigationtBarAndStatuBar)
make.height.equalTo(456.0)
}
animaiton() animaiton()
} }
...@@ -137,7 +180,54 @@ class YHMatchPeopleViewController: YHBaseViewController { ...@@ -137,7 +180,54 @@ class YHMatchPeopleViewController: YHBaseViewController {
UIView.animate(withDuration: 0.5, delay: 0.1, options: [.curveEaseInOut]) { UIView.animate(withDuration: 0.5, delay: 0.1, options: [.curveEaseInOut]) {
view1.y = 102+k_Height_NavigationtBarAndStatuBar view1.y = 102+k_Height_NavigationtBarAndStatuBar
} completion: { finish in } } completion: {
[weak self] finish in
guard let self = self else { return }
self.cardContainer.isHidden = false
view1.isHidden = true
view2.isHidden = true
view3.isHidden = true
}
}
}
extension YHMatchPeopleViewController: DragCardDataSource {
public func numberOfCards(_ dragCard: DragCardContainer) -> Int {
return matchCardsArr.count
}
public func dragCard(_ dragCard: DragCardContainer, viewForCard index: Int) -> DragCardView {
let cardView:YHNameCardInfoView = YHNameCardInfoView.createCardView()
cardView.allowedDirection = self.allowedDirection
if index % 3 == 0 {
cardView.cardView.backgroundColor = .white
} else if index % 3 == 1 {
cardView.cardView.backgroundColor = UIColor.init(hex: 0xE7EBF3)
} else if index % 3 == 2 {
cardView.cardView.backgroundColor = UIColor.init(hex: 0xC4CEE3)
}
return cardView
}
}
extension YHMatchPeopleViewController: DragCardDelegate {
public func dragCard(_ dragCard: DragCardContainer, displayTopCardAt index: Int, with cardView: DragCardView) {
print("displayTopCardAt: \(index)")
}
public func dragCard(_ dragCard: DragCardContainer, didRemovedTopCardAt index: Int, direction: Direction, with cardView: DragCardView) {
print("didRemovedTopCardAt: \(index)")
}
public func dragCard(_ dragCard: DragCardContainer, didRemovedLast cardView: DragCardView) {
print("didRemovedLast")
}
public func dragCard(_ dragCard: DragCardContainer, didSelectTopCardAt index: Int, with cardView: DragCardView) {
print("didSelectTopCardAt: \(index)")
} }
} }
...@@ -75,6 +75,8 @@ class YHFriendRequestView: UIView { ...@@ -75,6 +75,8 @@ class YHFriendRequestView: UIView {
btn.setTitleColor(.brandMainColor, for: .normal) btn.setTitleColor(.brandMainColor, for: .normal)
btn.titleLabel?.font = .PFSC_M(ofSize: 14) btn.titleLabel?.font = .PFSC_M(ofSize: 14)
btn.layer.cornerRadius = 3 btn.layer.cornerRadius = 3
btn.layer.borderWidth = 1.0
btn.layer.borderColor = UIColor.brandMainColor.cgColor
btn.addTarget(self, action: #selector(didCancelBtnClicked), for: .touchUpInside) btn.addTarget(self, action: #selector(didCancelBtnClicked), for: .touchUpInside)
return btn return btn
}() }()
...@@ -113,10 +115,11 @@ class YHFriendRequestView: UIView { ...@@ -113,10 +115,11 @@ class YHFriendRequestView: UIView {
} }
@objc func didCancelBtnClicked() { @objc func didCancelBtnClicked() {
dismiss()
} }
@objc func didSendBtnClicked() { @objc func didSendBtnClicked() {
dismiss()
} }
func createUI() { func createUI() {
...@@ -146,7 +149,7 @@ class YHFriendRequestView: UIView { ...@@ -146,7 +149,7 @@ class YHFriendRequestView: UIView {
cardView.snp.makeConstraints { make in cardView.snp.makeConstraints { make in
make.left.equalTo(38) make.left.equalTo(38)
make.right.equalTo(-38) make.right.equalTo(-38)
make.centerX.equalToSuperview() make.centerY.equalToSuperview()
make.height.equalTo(313) make.height.equalTo(313)
} }
......
...@@ -7,8 +7,9 @@ ...@@ -7,8 +7,9 @@
// //
import UIKit import UIKit
import DragCardContainer
class YHNameCardInfoView: UIView { class YHNameCardInfoView: DragCardView {
static let height = 456.0 static let height = 456.0
static let width = KScreenWidth-36.0*2 static let width = KScreenWidth-36.0*2
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment