SCCardView 1.1.0

SCCardView 1.1.0

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布最后发布2018年10月
SPM支持 SPM

myoungsc 维护。



  • myoung

SCCardView

CI Status Version License Platform

描述

一个通过选择卡片来更改内容的视图。内容可以自定义,但图像是必需的。您可以通过点击卡片或使用上下滑动手势来更改卡片。

屏幕截图

要求

* Swift 4.2
* XCode 10.0
* iOS 9.0 (Min SDK)

安装

SCCardView 通过 CocoaPods 可用。要安装它,只需将以下行添加到您的 Podfile

//Add Podfile
pod "SCCardView" //Swift 4.2
pod "SCCardView", '-> 1.0.0' //Swift 4.0
pod "SCCardView", '~> 0.2.0' //Swift 3.0

//After
pod install

使用方法

如果你使用URL,可以将键值设置为“url”。但“image”是一个必选参数。如果你使用“url”,则“image”键的值将输入到占位符图片中,如果可以为空。URL图片的渲染依赖于SDWebImage。

import SCCardView

// Int index, [String: String] key, Value
// Make dummy data (Necessary key Image Card UI)
let dummyData: [Int: [String: Any]] = [0: ["image": UIImage()!,
                                          "title": "Catholic Church",
                                          "url": "https://github.com/myoungsc/SCCardView/blob/master/Example/SCCardView/Images.xcassets/sc0.imageset/sc0.jpg?raw=true",
                                          "description": "Maybe famous Catholic Churchsadl"],
                                       1: ["image": UIImage(named: "sc1")!,
                                           "title": "Beautiful Sea",
                                           "description": "Beautiful sea anywhere on earth"],
                                       2: ["image": UIImage(named: "sc2")!,
                                          "title": "Famous temple",
                                           "description": "A landscape of famous temple"],
                                       3: ["image": UIImage(named: "sc3")!,
                                          "title": "Pretty Flower",
                                          "description": "Pretty Flower\nphoto  by myoung father"],
                                       4: ["image": UIImage(named: "sc4")!,
                                          "title":"Vast Sky",
                                          "description": "Vast korea sky\nphoto by myoung father"],
                                       5: ["image": UIImage(named: "sc5")!,
                                          "title": "Leaf",
                                          "description":"Leaf anywhere on Korea\nphoto by myoung father"]]

sccard.delegate = self
sccard.cardStyle = .onlyTop
//if cardstyle round cutom
/*
 sccard.cardStyle = .custom
 sccard.initCustomCardStyle([.topLeft, .bottomRight])
 */
sccard.initialViewData(dummyData)

// Set initial value
if let dicSubData: [String: Any] = dummyData[0] {
    if let img: UIImage = dicSubData["image"] as? UIImage,
        let title: String = dicSubData["title"] as? String,
        let des: String = dicSubData["description"] as? String {
        sccardSubImg.image = img
        sccardSubTitle.text = title
        sccardSubDes.text = des
    }
}
// Autolayout bottom card ratio
contBottomDes.constant = sccard.bottomInterval


// Delegate
// Selector Card Click. Required Delegate
func SCCardSelectorCard(_ index: Int, dic: [String: Any]) {
    if let img: UIImage = dic["image"] as? UIImage,
        let title: String = dic["title"] as? String,
        let des: String = dic["description"] as? String {
        sccardSubImg.image = img
        sccardSubTitle.text = title
        sccardSubDes.text = des
    }
}

// Refresh content view from down image. Required Delegate
func SCCardURLIndexRefresh(_ img: UIImage) {
    sccardSubImg.image = img
}

// Card Down Gesture. optional Delegate
internal func SCCardDownCardAction(_ indexPath: IndexPath) {
    print("down gesture \(indexPath)")
}

// Card Up Gesture. optional Delegate
internal func SCCardUpCardAction(_ indexPath: IndexPath) {
    print("up gesture \(indexPath)")
}

作者

myoung

首页

[email protected]

许可协议

SCPageControl 在MIT许可下可用。有关更多信息,请参阅LICENSE文件。