[翻译] LTInfiniteScrollView
LTInfiniteScrollView

效果:

Usage - 使用
Create the scroll view by:
通过以下方式来创建出scroll view
self.scrollView = [[LTInfiniteScrollView alloc]initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.view.bounds), 200)];
[self.view addSubview:self.scrollView];
self.scrollView.dataSource = self;
[self.scrollView reloadData];
Then implement LTInfiniteScrollViewDataSource protocol:
然后实现LTInfiniteScrollViewDataSource协议方法:
@protocol LTInfiniteScrollViewDataSource <NSObject>
-(UIView*) viewAtIndex:(int)index reusingView:(UIView *)view;
-(int) totalViewCount;
-(int) visibleViewCount;
@end
Sample code:
示例源码:
-(int) totalViewCount
{
// you can set it to a very big number to mimic the infinite behavior, no performance issue here
return 100000000;
} -(int) visibleViewCount
{
return 5;
} -(UIView*) viewAtIndex:(int)index reusingView:(UIView *)view;
{
if(view){
((UILabel*)view).text = [NSString stringWithFormat:@"%d", index];
return view;
} UILabel *aView = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 64, 64)];
aView.backgroundColor = [UIColor blackColor];
aView.layer.cornerRadius = 32;
aView.layer.masksToBounds = YES;
aView.backgroundColor = [UIColor colorWithRed:0/255.0 green:175/255.0 blue:240/255.0 alpha:1];
aView.textColor = [UIColor whiteColor];
aView.textAlignment = NSTextAlignmentCenter;
aView.text = [NSString stringWithFormat:@"%d", index];
return aView;
}
If you want to apply any animation during scrolling, implement LTInfiniteScrollViewDelegateprotocol:
如果你想在滑动期间实现其他的动画效果,实现这个LTInfiniteScrollViewDelegateprotocol协议即可:
@protocol LTInfiniteScrollViewDelegate <NSObject>
-(void) updateView:(UIView*) view withDistanceToCenter:(CGFloat)distance scrollDirection:(ScrollDirection)direction;
@end
See the example for details~
请从示例源码中查看更多的细节~
[翻译] LTInfiniteScrollView的更多相关文章
- 《Django By Example》第五章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者@ucag注:大家好,我是新来的翻译, ...
- 《Django By Example》第四章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:祝大家新年快乐,这次带来<D ...
- [翻译]开发文档:android Bitmap的高效使用
内容概述 本文内容来自开发文档"Traning > Displaying Bitmaps Efficiently",包括大尺寸Bitmap的高效加载,图片的异步加载和数据缓存 ...
- 【探索】机器指令翻译成 JavaScript
前言 前些时候研究脚本混淆时,打算先学一些「程序流程」相关的概念.为了不因太枯燥而放弃,决定想一个有趣的案例,可以边探索边学. 于是想了一个话题:尝试将机器指令 1:1 翻译 成 JavaScript ...
- 《Django By Example》第三章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:第三章滚烫出炉,大家请不要吐槽文中 ...
- 《Django By Example》第二章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:翻译完第一章后,发现翻译第二章的速 ...
- 《Django By Example》第一章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:本人目前在杭州某家互联网公司工作, ...
- 【翻译】Awesome R资源大全中文版来了,全球最火的R工具包一网打尽,超过300+工具,还在等什么?
0.前言 虽然很早就知道R被微软收购,也很早知道R在统计分析处理方面很强大,开始一直没有行动过...直到 直到12月初在微软技术大会,看到我软的工程师演示R的使用,我就震惊了,然后最近在网上到处了解和 ...
- ASP.NET MVC with Entity Framework and CSS一书翻译系列文章之第一章:创建基本的MVC Web站点
在这一章中,我们将学习如何使用基架快速搭建和运行一个简单的Microsoft ASP.NET MVC Web站点.在我们马上投入学习和编码之前,我们首先了解一些有关ASP.NET MVC和Entity ...
随机推荐
- springMVC与Struts2区别
1.拦截级别 Struts2是类级别的拦截,一个类对应一个request上下文 SpringMVC是方法级别的拦截,一个方法对应一个request上下文,而方法同时又跟一个url对应 所以说从架构本身 ...
- JavaScript数据结构-7.链表
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- manjaro 添加tash 快捷方式
-In your home directory open /.local/share/applications/-Right click in this folder and create a emp ...
- 第七章、Linux 文件与目录管理
第七章.Linux 文件与目录管理 1. 目录与路径 1.1 相对路径与绝对路径 1.2 目录的相关操作: cd, pwd, mkdir, rmdir 1.3 关於运行档路径的变量: $PATH ...
- Ruby(3):基本语法中
字符串分割成数组: 可以使用先scan再join的方法,当然其实有更好的 split方法,专门用来分割字符串 # 在Ruby中,如果不使用inspect,直接使用puts输出数组,那么每个元素会占用一 ...
- 控件--spinner(列表选项框)
1. 关键点 1). Spinner的菜单显示方式 它有两种显示形式,一种是下拉菜单,一种是弹出框,菜单显示形式是spinnerMode属性决定的: android:spinnerMode=" ...
- [转]使用ASP.NET Web Api构建基于REST风格的服务实战系列教程【八】——Web Api的安全性
本文转自:http://www.cnblogs.com/fzrain/p/3552423.html 系列导航地址http://www.cnblogs.com/fzrain/p/3490137.html ...
- Knockout.js CSS绑定
<head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8&quo ...
- Spring.Net---3、IoC/DI深入理解
------------------------------------------------------------------------ 理解IoC/DI 1.控制反转 --> 谁控制谁 ...
- c#参数修饰符-out
out 关键字通过引用传递参数. 方法定义和调用方法必须显式使用out关键字: 调用方法时参数不必初始化,方法内必须对其赋值: 参数中可以声明多个out修饰的参数. 例: public void Us ...