Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 472
jasan Avatar asked Aug 20 '15 07:08

jasan


2 Answers

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!

}
like image 57
Lengo Avatar answered Oct 01 '22 06:10

Lengo


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.

like image 37
user3579086 Avatar answered Oct 01 '22 08:10

user3579086