iOS开发-UIRefreshControl下拉刷新
下拉刷新一直都是第三库的天下,有的第三库甚至支持上下左右刷新,UIRefreshControl是iOS6之后支持的一个刷新控件,不过由于功能单一,样式不能自定义,因此不能满足大众的需求,用法比较简单在UITableview和UICollectionview上面直接添加子视图即可使用。
代码调用:
1 2 3 4 5 6 7 | self .refreshControl = [[UIRefreshControl alloc] init]; [_refreshControl addTarget: self action: @selector (refreshView:) forControlEvents:UIControlEventValueChanged]; [ self .refreshControl setAttributedTitle:[[ NSAttributedString alloc] initWithString:@ "数据加载-FlyElephant" ]]; [ self .refreshControl setTintColor:[UIColor redColor]]; [ self .tableView addSubview: self .refreshControl]; |
刷新回调:
1 2 3 4 5 6 | -( void )refreshView:(UIRefreshControl *)control{ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3.0 * NSEC_PER_SEC )), dispatch_get_main_queue(), ^{ [ self .refreshControl endRefreshing]; NSLog (@ "原文地址:http://www.cnblogs.com/xiaofeixiang" ); }); } |
当然如果有合适的图片我们可以覆盖加载的图片:
1 2 3 4 | self .loadingImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed: @ "RefreshIcon" ]]; self .loadingImageView.center = CGPointMake(CGRectGetMidX( self .view.bounds), 30); [ self .refreshControl insertSubview: self .loadingImageView atIndex:0]; [ self .refreshControl bringSubviewToFront: self .loadingImageView]; |
实现效果不是很好:
本文转自Fly_Elephant博客园博客,原文链接:http://www.cnblogs.com/xiaofeixiang/p/4668815.html,如需转载请自行联系原作者
低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。
持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。
转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。
- 上一篇
iOS开发-UIScreenEdgePanGestureRecognizer实战
UIScreenEdgePanGestureRecognizer名字很长,而且关于其文档也是少的的可怜,苹果官方给的唯一的一个属性是edges,文档中的解释是这样的: 1 A UIScreenEdgePanGestureRecognizer looks for panning (dragging) gestures that start near an edge of the screen. The system uses screen edge gestures in some cases to initiate view controller transitions. You can use this class to replicate the same gesture behavior for your own actions. 大概的意思就是UIScreenEdgePanGestureRecognizer跟pan(平移)手势差不多,需要从边缘进行拖动,在控制器转换的时候是有用的,看文档的话我们会发现UIScreenEdgePanGestureRecognizer是UIPanG...
- 下一篇
带波浪效果的CollapsingToolbarLayout + RecycleView
小菜最近接到一个任务,实现包括波浪条的可折叠的ToolBar,准备用CollapsingToolbarLayout来尝试一下: 1. 根据使用手册和网上大神们的例子,布局文件中 CollapsingToolbarLayout 里面添加需要展示的 Toolbar 和其他需要展示的控件,包括文字图片和需要自定义的波浪 View; 2. CollapsingToolbarLayout 中,需要设置 layout_scrollFlags 中 scroll(滚动)/enterAlways(实现 quick return 效果, 当向下移动时,立即显示View)/exitUntilCollapsed(向上滚动时收缩View,但可以固定Toolbar一直在上面)/enterAlwaysCollapsed(当View已经设置minHeight属性又使用此标志时,你的View只能以最小高度进入,只有当滚动视图到达顶部时才扩大到完整高度); CollapsingToolbarLayout 里面的控件一般需要设置: (1) layout_collapseMode (折叠模式) -有两个值: ...
相关文章
文章评论
共有0条评论来说两句吧...
文章二维码
点击排行
推荐阅读
最新文章
- CentOS8,CentOS7,CentOS6编译安装Redis5.0.7
- SpringBoot2整合Redis,开启缓存,提高访问速度
- CentOS7,8上快速安装Gitea,搭建Git服务器
- Docker使用Oracle官方镜像安装(12C,18C,19C)
- CentOS关闭SELinux安全模块
- SpringBoot2初体验,简单认识spring boot2并且搭建基础工程
- MySQL8.0.19开启GTID主从同步CentOS8
- Hadoop3单机部署,实现最简伪集群
- 设置Eclipse缩进为4个空格,增强代码规范
- CentOS7,CentOS8安装Elasticsearch6.8.6