项目介绍:
LXCarouselImages
https://github.com/LXfeiYu/LXCarouselImages
功能:
1.可以选择开启和关闭定时器
2.有点击事件
使用方法:
//添加轮播图
let showView = LXShowView.init(frame: CGRect(x:0,y:20,width:self.view.frame.size.width,height:200))
showView.isUserInteractionEnabled = true
showView.delegate = self
//关闭定时器
// showView.isOpenTimer = false
self.view.addSubview(showView)
//数据
let path = Bundle.main.path(forResource: "imageData", ofType: "json")
let jsonData = NSData.init(contentsOfFile: path!)
//方法1 使用NSJSONSerialization解析
do {
let json = try JSONSerialization.jsonObject(with: jsonData! as Data, options:[]) as! [String:AnyObject]
let array=json["json"] as! NSArray
for imageData in array{
let dict = imageData as! NSDictionary
// print(dict["title"]!)
let model = Model.init(imageName: dict["imageName"] as! String, title: dict["title"] as! String)
showView.dataArray.append(model)
}
}catch let error as NSError{
print("解析出错。\(error.localizedDescription)")
}
点击事件
//点击轮播图
func clickImageView(index:NSInteger){
print("点击第\(index)个")
}
有喜欢玩博客园的朋友吗? 可以加个好友 http://www.cnblogs.com/xingsmile/