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~

请从示例源码中查看更多的细节~

最新文章

  1. 自定义Inspector检视面板
  2. sql单表中某一字段重复,取最近3条或几条数据
  3. iftop 安装以及相关参数及说明(转载自csdn)
  4. Java中的super与this解析
  5. 亲和数[HDU2040]
  6. css float对于之后布局的影响
  7. hdu 2426 Interesting Housing Problem 最大权匹配KM算法
  8. lintcode:合并两个排序链表
  9. *IntelliJ IDEA使用Hibernate连接数据库
  10. Android学习【Android内核编译流程和错误笔记】
  11. 2301: [HAOI2011]Problem b
  12. Struts2+Spring+Hibernate step by step 11 ssh拦截验证用户登录到集成
  13. 检测网站挂马程序(Python)
  14. QTREE5 - Query on a tree V——LCT
  15. 软件补丁问题(SPFA+位运算)
  16. Java的参数传递是「按值传递」还是「按引用传递」?
  17. 20165327 2017-2018-2《Java程序设计》课程总结
  18. Java基础——GUI编程(三)
  19. artTemplate 原生 js 模板语法版
  20. Eclipse中如何安装和使用GrepCode插件 (转)

热门文章

  1. EJB与JavaBean
  2. IDEA Maven Mybatis generator 自动生成代码
  3. CentOS6.4安装OpenSSL
  4. 使用C++11 开发一个半同步半异步线程池
  5. 09 jdk1.5的并发容器:ConcurrentHashMap
  6. Field [_id] is a metadata field and cannot be added inside a document. Use the index API request parameters--转
  7. Java 动态代理机制分析及扩展--转
  8. td 不换行 隐藏显示多余的部分(转)
  9. 云主机安装Tomcat上传自己的网站
  10. jQuery选择器,外加例子讲解