swift 使用MAGearRefreshControl控件刷新
来源:互联网 发布:pk10网站源码 编辑:程序博客网 时间:2024/06/07 07:17
class ThridViewController:UIViewController, UITableViewDataSource,UITableViewDelegate,MAGearRefreshDelegate { var _tableView:UITableView! var refreshControlView:MAGearRefreshControl! var isLoading =false overridefunc viewDidLoad() { super.viewDidLoad(); self.navigationController?.navigationBar.translucent = false var screeSize:CGSize =UIScreen.mainScreen().bounds.size _tableView =UITableView(frame: CGRectMake(0,0, screeSize.width, screeSize.height), style: .Plain) _tableView.dataSource =self _tableView.delegate =self self.view.addSubview(_tableView) refreshControlView =MAGearRefreshControl(frame: CGRectMake(0, -_tableView.bounds.height,self.view.frame.width,_tableView.bounds.height)) refreshControlView.backgroundColor = UIColor.initRGB(234, g:234, b: 234) refreshControlView.addInitialGear(nbTeeth:12, color:UIColor.initRGB(40, g:40, b: 40), radius:16) refreshControlView.addLinkedGear(0, nbTeeth:16, color: UIColor.initRGB(80, g:80, b: 80).colorWithAlphaComponent(0.8), angleInDegree:30) refreshControlView.addLinkedGear(0, nbTeeth:32, color: UIColor.initRGB(104, g:104, b: 104).colorWithAlphaComponent(0.4), angleInDegree:190) refreshControlView.addLinkedGear(1, nbTeeth:40, color: UIColor.initRGB(104, g:104, b: 104).colorWithAlphaComponent(0.4), angleInDegree: -30) refreshControlView.addLinkedGear(2, nbTeeth:24, color: UIColor.initRGB(80, g:80, b: 80).colorWithAlphaComponent(0.8), angleInDegree: -190) refreshControlView.addLinkedGear(3, nbTeeth:10, color: UIColor.initRGB(80, g:80, b: 80), angleInDegree:40) refreshControlView.setMainGearPhase(0) refreshControlView.delegate =self refreshControlView.barColor =UIColor.initRGB(200, g:200, b: 200) _tableView.addSubview(refreshControlView) } func tableView(tableView:UITableView, numberOfRowsInSection section:Int) -> Int { return20; } func tableView(tableView:UITableView, cellForRowAtIndexPath indexPath:NSIndexPath) -> UITableViewCell { var identiferString ="Cell_\(indexPath.row)" var cell :UITableViewCell? = tableView.dequeueReusableCellWithIdentifier(identiferString)as? UITableViewCell if(cell ==nil){ cell = UITableViewCell(style:UITableViewCellStyle.Default, reuseIdentifier: identiferString) } cell?.textLabel?.text ="Row \(indexPath.row)" return cell!; } //MARK: - UIScrollViewDelegate protocol conformance func scrollViewDidScroll(scrollView:UIScrollView) { refreshControlView.MAGearRefreshScrollViewDidScroll(scrollView) } func scrollViewDidEndDragging(scrollView:UIScrollView, willDecelerate decelerate:Bool) { refreshControlView.MAGearRefreshScrollViewDidEndDragging(scrollView) } overridefunc didRotateFromInterfaceOrientation(fromInterfaceOrientation:UIInterfaceOrientation) { refreshControlView.frame =CGRectMake(0, -_tableView.bounds.height,self.view.frame.size.width,_tableView.bounds.size.height) } //MARK: - MAGearRefreshDelegate protocol conformance func MAGearRefreshTableHeaderDataSourceIsLoading(view:MAGearRefreshControl) -> Bool { returnisLoading } func MAGearRefreshTableHeaderDidTriggerRefresh(view:MAGearRefreshControl) { refresh() } func refresh(){ isLoading =true // -- DO SOMETHING AWESOME (... or just wait 3 seconds) -- // This is where you'll make requests to an API, reload data, or process information var delayInSeconds =0.6 var popTime =dispatch_time(DISPATCH_TIME_NOW,Int64(delayInSeconds * Double(NSEC_PER_SEC))) dispatch_after(popTime,dispatch_get_main_queue()) { () ->Void in // When done requesting/reloading/processing invoke endRefreshing, to close the control self.isLoading =false self.refreshControlView.MAGearRefreshScrollViewDataSourceDidFinishedLoading(self._tableView) } } }
0 0
- swift 使用MAGearRefreshControl控件刷新
- swift基本控件使用
- 【swift】使用oc的控件
- 下拉刷新控件SwipeRefreshLayout使用
- 头部下拉刷新控件使用
- swift基础语法之控件使用02
- Android 下拉刷新控件的使用
- 官方下拉刷新控件SwipeRefreshLayout的使用
- Android 下拉刷新控件SwipeRefreshLayout 的使用
- Android 下拉刷新控件的使用
- 关于使用刷新控件的思考
- Android SwipeRefreshLayout 官方下拉刷新控件使用
- PullToRefresh第三方刷新控件使用总结
- android 下拉刷新控件SwipeRefreshLayout简单使用
- Android万能下拉刷新控件SwipeRefleshLayout使用
- SwipeRefreshLayout下拉刷新控件的使用
- Android-SwipeRefreshLayout下拉刷新控件使用
- materialdesign下拉刷新控件MaterialRefreshLayout的使用
- 千里之行,始于足下
- 关于PO,POJO,VO
- 好用的工具--记录
- CentOS7 配置 vsftpd
- CHROME源码剖析 上《转》
- swift 使用MAGearRefreshControl控件刷新
- 关于死锁
- 背景音乐实现功能
- Hibernate中update方法的注意点
- android EditText默认问题
- win8.1下无法运行vc++6.0的解决方法
- 关于CentOS网络连接问题及第三天实习收获
- python中的input函数和raw_input函数的区别
- 二叉树的前序、中序、后序、层序遍历