Created
September 28, 2016 13:45
-
-
Save paulw11/d67bb9d146157cca556b72dd25ca65cf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ViewController.swift | |
// carouselTest | |
// | |
// Created by Paul Wilkinson on 28/09/2016. | |
// Copyright © 2016 Paul Wilkinson. All rights reserved. | |
// | |
import UIKit | |
import iCarousel | |
class ViewController: UIViewController, iCarouselDataSource { | |
@IBOutlet weak var carousel1: iCarousel! | |
@IBOutlet weak var carousel2: iCarousel! | |
let values1 = ["one","two","three","four","five","six","seven"] | |
let values2 = ["A","B","C","D","E","F"] | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Do any additional setup after loading the view, typically from a nib. | |
} | |
override func didReceiveMemoryWarning() { | |
super.didReceiveMemoryWarning() | |
// Dispose of any resources that can be recreated. | |
} | |
func numberOfItemsInCarousel(carousel: iCarousel) -> Int { | |
var count = 0 | |
switch carousel { | |
case carousel1: | |
count = self.values1.count | |
case carousel2: | |
count = self.values2.count | |
default: | |
print("Unknown carousel") | |
} | |
return count | |
} | |
func carousel(carousel: iCarousel, viewForItemAtIndex index: Int, reusingView view: UIView?) -> UIView { | |
let view = UILabel(frame: CGRect(x: 0, y: 0, width: 130, height: 120)) | |
view.backgroundColor = UIColor.whiteColor().colorWithAlphaComponent(0.5) | |
view.textColor = UIColor.blackColor() | |
var val: String = "" | |
switch carousel { | |
case carousel1: | |
val = self.values1[index] | |
case carousel2: | |
val = self.values2[index] | |
default: | |
print("Unknown carousel") | |
} | |
view.text = val | |
return view | |
} | |
func carouselItemWidth(carousel: iCarousel) -> CGFloat { | |
return 135.0 | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment