An infinite-scroll banner implemented with two views, includes Swift and Objective-C APIs.
An infinite scroll control implemented with two views, supporting custom reuse of views.
Objective-C
Swift
LCInfiniteScrollView *v = [[LCInfiniteScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 300)];
v.backgroundColor = UIColor.brownColor;
v.delegate = self;
v.autoScroll = YES;
[self.view addSubview:v];
let banner = LCInfiniteScrollView(frame: CGRect(x: 0, y: 0, width: self.view.frame.size.width, height: 200))
banner.delegate = self
banner.autoScroll = true
self.view.addSubview(banner)
- (UIView *)reusableViewInInfiniteScrollView:(LCInfiniteScrollView *)infiniteScrollView {
UILabel *label = [UILabel new];
label.font = [UIFont boldSystemFontOfSize:30];
label.textAlignment = NSTextAlignmentCenter;
return label;
}
- (void)infiniteScrollView:(LCInfiniteScrollView *)infiniteScrollView displayReusableView:(UIView *)reusableView atIndex:(NSInteger)index {
UILabel *label = (UILabel *)reusableView;
label.text = @(index).stringValue;
label.backgroundColor = (UIColor *)self.colors[index];
}
func infiniteScrollView(_ infiniteScrollView: LCInfiniteScrollView, displayReusableView view: UIView, forIndex index: Int) {
view.backgroundColor = colors[index]
}
func reusableView(in infiniteScrollView: LCInfiniteScrollView) -> UIView {
return UIView()
}
To integrate LCInfiniteScrollView into your Xcode project using CocoaPods, specify it in your Podfile
:
pod 'LCInfiniteScrollView'
pod 'SwiftInfiniteScrollView'
LCInfiniteScrollView.h
.LCInfiniteScrollView is provided under the MIT license. See LICENSE file for details.