using Yalantis/Koloda library to load more than just 1 UIView

☆樱花仙子☆ 提交于 2019-12-10 14:02:26

问题


So I'm using this library and in the example provided only static images are used to load into each card. however I want to customize the look and feel of the each card with labels, multiples UImages etc that i will load from parse.com . How can I achieve this. the function func kolodaViewForCardAtIndex(koloda: KolodaView, index: UInt) -> UIView {

}

Only return UIview. Any suggestions.


回答1:


I've done the following and it works. Create a custom interface (.xib) view and class (in my example its called "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!

}



回答2:


Data source method

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

Takes any UIView. So just create the view you need(for example from xib) and return it in this method.



来源:https://stackoverflow.com/questions/32111556/using-yalantis-koloda-library-to-load-more-than-just-1-uiview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!