使用Yalantis/Koloda库加载超过1 UIView

jas*_*san 5 mobile github uiview ios swift

所以我正在使用这个 ,在提供的示例中,只使用静态图像加载到每张卡中.但是我想用parse.com加载的标签,倍数UImages等来自定义每张卡的外观和感觉.我怎样才能做到这一点.函数func kolodaViewForCardAtIndex(koloda:KolodaView,index:UInt) - > UIView {

}

仅返回UIview.有什么建议.

Len*_*ngo 6

我已经完成了以下工作.创建自定义接口(.xib)视图和类(在我的示例中称为"CustomView")

    func koloda(kolodaNumberOfCards koloda:KolodaView) -> UInt {
    return UInt(self.run.count)
}

func koloda(koloda: KolodaView, viewForCardAtIndex index: UInt) -> UIView {

    let cell = NSBundle.mainBundle().loadNibNamed("CustomView", owner: self, options: nil).first as? CustomView
    let runs = self.run[Int(index)]
    cell!.textLabel!.text = runs.type
    return cell!

}
Run Code Online (Sandbox Code Playgroud)


use*_*086 2

数据来源方法

 func kolodaViewForCardAtIndex(koloda: KolodaView, index: UInt) -> UIView
Run Code Online (Sandbox Code Playgroud)

接受任何 UIView。因此,只需创建您需要的视图(例如来自 xib)并在此方法中返回它。