在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
使用三个UIButton实现无限轮播:https://github.com/LXfeiYu/LXCarouselImages.git 喜欢的朋友给个星!!! 功能: 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)个") }
|
请发表评论