选择时间间隔(集合视图)

时间:2017-02-21 11:41:42

标签: swift uicollectionview

enter image description here 在我的项目中,我必须选择时间间隔(范围)作为下图。

这是我正在使用的代码,我添加了一个collectionView:

  class ViewController: UIViewController , UICollectionViewDelegate, UICollectionViewDataSource{
@IBOutlet var collectionView: UICollectionView!
var time = ["0.00","1.00","2.00","3.00","4.00","5.00","6.00","7.00","8.00","9.00","10.00","11.00","12.00","1.00","2.00","3.00","4.00","5.00","6.00","7.00","8.00","9.00","10.00","11.00"]
var timeVal = ["AM","AM","AM","AM","AM","AM","AM","AM","AM","AM","AM","AM","PM","PM","PM","PM","PM","PM","PM","PM","PM","PM","PM","PM"]

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 collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
    return time.count

}
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {


        let cell = collectionView.dequeueReusableCellWithReuseIdentifier("cell", forIndexPath: indexPath) as! timeCell

    cell.timeLabel.text = time[indexPath.row]
    cell.intervalLabel.text = timeVal[indexPath.row]
        return cell

    }
    func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
        return CGSizeMake((collectionView.frame.size.width/7) , (collectionView.frame.size.height))
    }
}

我看起来如下图所示: enter image description here

但我很困惑如何实现间隔选择(两个时间间隔)。请建议。

0 个答案:

没有答案