我正在使用iCarosuel并且我有一个填充的数组,它会显示,但是当我滚动并停止某个值时,我希望打印该值。无论卷轴停止的值是什么,都打印该值。
func carousel(carousel: iCarousel, viewForItemAtIndex index: Int, reusingView view: UIView?) -> UIView {
var labels: UILabel
var itemView: UIImageView
if(view == nil){
itemView = UIImageView(frame:CGRect(x:0, y:0, width:400, height:100))
itemView.image = UIImage(named: "page")
itemView.contentMode = .Center
labels = UILabel(frame: itemView.bounds)
labels.backgroundColor = UIColor.clearColor()
labelsubject.textAlignment = .Center
labels.textColor = UIColor.whiteColor()
labels.tag = 1
itemView.addSubview(labels)
}else{
itemView = view as! UIImageView;
labels = itemView.viewWithTag(1) as! UILabel!
}
labels.text = "\(text[index])"
return itemView
}
答案 0 :(得分:0)
func carouselDidEndDragging(carousel: iCarousel, willDecelerate decelerate: Bool) {
if !decelerate {
print(carousel.currentItemIndex)
//text[carousel.currentItemIndex]
}
}
func carouselDidEndDecelerating(carousel: iCarousel) {
print(carousel.currentItemIndex)
//text[carousel.currentItemIndex]
}