swift3自定义下拉刷新控件(二)QQ弹簧效果
来源:互联网 发布:淘宝网什么时候搞活动 编辑:程序博客网 时间:2024/05/16 02:01
1、请在命令行输入
pod search tgrefreshswift
2、弹出下面提示说明可以使用
3、在你的podfile中导入tgrefreshswift
即这一句
pod 'TGRefreshSwift'
# Uncomment the next line to define a global platform for your project# platform :ios, '9.0'target 'TGRefreshSwiftDemo' do # Comment the next line if you're not using Swift and don't want to use dynamic frameworks use_frameworks! # Pods for TGRefreshSwiftDemopod 'TGRefreshSwift'end
过程图
4、使用控件
//// ViewController.swift// TGRefreshSwiftDemo//// Created by targetcloud on 2017/6/26.// Copyright © 2017年 targetcloud. All rights reserved.//import UIKitimport TGRefreshSwiftclass ViewController: UIViewController { @IBOutlet weak var tv: UITableView! fileprivate let identifier = "cell" fileprivate var dataCount: Int = 10 override func viewDidLoad() { super.viewDidLoad() tv.dataSource = self tv.delegate = self tv.tableFooterView = UIView() tv.allowsSelection = false self.automaticallyAdjustsScrollViewInsets=false builderRecommend5() } @objc fileprivate func loadDataSenior(){ DispatchQueue.main.asyncAfter(deadline: DispatchTime.now()+2) { let isSuccess = arc4random_uniform(3) % 2 == 0 let count = isSuccess ? arc4random_uniform(20) : 0 self.dataCount = count>0 ? Int(count) : self.dataCount self.tv.tg_header?.refreshResultStr = count>0 ? "成功刷新到\(count)条数据,来自TGRefreshSwift" : "请先在Github上Star本控件:-)" self.tv.tg_header?.isSuccess = isSuccess isSuccess ? self.tv.reloadData() : () self.tv.tg_header?.endRefreshing() } }}extension ViewController{ //QQ效果 fileprivate func builderRecommend(){ self.tv.tg_header = TGRefreshSwift.refresh(self, #selector(loadDataSenior)) self.tv.tg_header?.beginRefreshing() } //QQ效果 fileprivate func builderRecommend2(){ self.tv.tg_header = TGRefreshSwift.refresh() self.tv.tg_header?.addTarget(self, action: #selector(loadDataSenior), for: .valueChanged) self.tv.tg_header?.beginRefreshing() } //一般平常效果 fileprivate func builderRecommend3(){ self.tv.tg_header = TGRefreshSwift.refresh(self, #selector(loadDataSenior)){(refresh) in refresh.tg_kind(.Common) } self.tv.tg_header?.beginRefreshing() } //更多配置 fileprivate func builderRecommend4(){ self.tv.tg_header = TGRefreshSwift.refresh(self, #selector(loadDataSenior)){(refresh) in refresh.tg_refreshResultBgColor(UIColor.orange.withAlphaComponent(0.8)) .tg_fadeinTime(2) .tg_verticalAlignment(.Midden) .tg_fadeoutTime(1) .tg_bgColor(UIColor(white:0.8,alpha:1)) } self.tv.tg_header?.beginRefreshing() } //扩展用法 fileprivate func builderRecommend5(){ self.tv.tg_header = TGRefreshSwift.refresh(self, #selector(loadDataSenior),44,UIImageView(image: UIImage(named: "profile_cover_background")) ){(refresh) in refresh.tg_refreshResultBgColor(UIColor.orange.withAlphaComponent(0.8)) .tg_verticalAlignment(.Midden) .tg_tinColor(UIColor.white) .tg_tipLabelFontSize(13) .tg_resultLabelFontSize(15) .tg_tipFailStyle(.tipInfoWhite) .tg_tipOKStyle(.tipOKWhite) .tg_fadeinTime(1) .tg_fadeoutTime(0.5) .tg_bgColor(UIColor(white:0.8,alpha:1)) } self.tv.tg_header?.beginRefreshing() }}extension ViewController: UITableViewDataSource,UITableViewDelegate{ func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return dataCount } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { var cell: UITableViewCell? = tableView.dequeueReusableCell(withIdentifier: identifier) if cell == nil { cell = UITableViewCell(style: UITableViewCellStyle.default, reuseIdentifier: identifier) } cell?.textLabel?.text = "第\(indexPath.row)行测试数据" return cell! } func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { return 44 }}
完整使用说明请参见
https://github.com/targetcloud/TGRefreshSwift
阅读全文
0 0
- swift3自定义下拉刷新控件(二)QQ弹簧效果
- swift3自定义下拉刷新控件(一)
- 自定义下拉刷新控件-仿美团刷新效果
- Swift3.0 -- UIRefreshControl添加下拉刷新控件
- 自定义控件--下拉刷新
- 自定义控件-下拉刷新
- 自定义控件--下拉刷新
- 自定义下拉刷新控件
- 自定义控件:下拉刷新
- Android 自定义View UC下拉刷新效果(二)
- 自定义控件 CustomListView (下拉刷新)
- WindowsPhone下拉刷新控件 - PullRefreshListBox(二)
- SwipeRefreshLayout 下拉刷新控件(二)
- 仿美团下拉刷新控件(二)
- 自定义下拉刷新控件-CBStoreHouseRefreshControl
- 自定义下拉刷新控件-CBStoreHouseRefreshControl
- 自定义下拉刷新控件-CBStoreHouseRefreshControl
- 自定义下拉刷新控件-CBStoreHouseRefreshControl
- 225.map7-定位
- iOS 最新 APP 提交上架流程~(打包 ipa)
- spark性能优化:数据倾斜调优
- spark性能优化:数据倾斜调优
- BSidesSF-2017-pinlock-150
- swift3自定义下拉刷新控件(二)QQ弹簧效果
- 树上取数
- clipboard.js实现复制功能
- CF Okabe and Boxes
- OC基础-@property,@synthesize和@dynamic 16
- AxonFramework,SpringBoot自动配置
- OC基础-静态类型,动态类型,编译检查,运行检查,父子类指针和对象互指17
- Element对象的firstchild和lastChild获取属性值的undefined问题
- JBDC+mysql Notes