UPCardsCarousel 1.0.2

UPCardsCarousel 1.0.2

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布日期上次发布2015年2月

Paul Ulric 维护。



  • Paul Ulric

UPCardsCarousel 是一个用于 iOS 的基于卡片的轮播效果。

demo

要求

UPCardsCarousel 使用 ARC 并需要 iOS 7.0+ 版本。

适用于 iPhone。

安装

手动安装

只需将 UPCardsCarousel 文件夹复制到您的项目,然后在 XCode 中导入即可。

使用方法

首先导入头文件

#import "UPCardsCarousel.h"

现在,您可以通过提供它的框架来创建一个 UPCardsCarousel 对象

UPCardsCarousel *carousel = [[UPCardsCarousel alloc] initWithFrame:aFrame];

然后您需要为它分配

  • 一个符合 UPCardsCarouselDelegate 协议的 delegate 对象
  • 一个符合 UPCardsCarouselDataSource 协议的 dataSource 对象

数据源

数据源通过两个简单易懂的方法告知轮播器卡片总数和每张卡片的内容

  • - (NSUInteger)carousel:(UPCardsCarousel *)carousel numberOfCards (必需的)
  • - (UIView *)carousel:(UPCardsCarousel *)carousel viewForCardAtIndex:(NSUInteger)index (必需的)

横幅中的标签通过可选方法提供。如果数据源没有实现此方法,则不会显示标签横幅。

  • - (NSString *)carousel:(UPCardsCarousel *)carousel labelForCardAtIndex:(NSUInteger)index (可选的)

委托

委托是可选的,当某些事件发生时,它将得到通知

  • - (void)carousel:(UPCardsCarousel *)carousel didTouchCardAtIndex:(NSUInteger)index
  • - (void)carousel:(UPCardsCarousel *)carousel willDisplayCardAtIndex:(NSUInteger)index
  • - (void)carousel:(UPCardsCarousel *)carousel willHideCardAtIndex:(NSUInteger)index
  • - (void)carousel:(UPCardsCarousel *)carousel didDisplayCardAtIndex:(NSUInteger)index
  • - (void)carousel:(UPCardsCarousel *)carousel didHideCardAtIndex:(NSUInteger)index

方法

方法 描述
reloadData 重新加载轮播器数据,重新创建可见的卡片并移动到卡片堆栈顶部
reloadDataWithCurrentIndex:(NSUInteger)index 重新加载轮播器数据,重新创建可见的卡片并将视图移动到卡片堆栈中指定的索引
reloadNumberOfCards 只重新加载轮播器中的卡片数量,不更改可见的卡片
reloadCardAtIndex:(NSUInteger)index 重新创建指定索引处的卡片
cardAtIndex:(NSUInteger)index 返回指定索引处的卡片视图

定制

卡片组

通常情况下,轮播图不会一次性显示由数据源提供的所有卡片。它会通过在两端销毁和创建卡片来处理无限的滚动过程。可见卡片的数量是固定的,可以通过以下属性自定义

  • maxVisibleCardsCount(默认为6)

您可以使用此属性自定义隐藏卡片组和可见卡片组之间卡片移动的持续时间

  • movingAnimationDuration(默认为0.4秒)

默认情况下,当在第一个隐藏卡片上进行双击时,轮播图将返回到卡片组的顶部。

Double-tap to top

您可以通过将doubleTapToTop属性设置为NO来禁用此行为。

标签横幅

您可以通过这两种方法自定义横幅的文本字体和颜色

  • - (void)setLabelFont:(UIFont *)font(默认为系统字体)
  • - (void)setLabelTextColor:(UIColor*)color(默认为黑色彩色)

您可以通过labelBannerPosition属性在两个位置中选择一个用于横幅

  • UPCardsCarouselLabelBannerLocation_bottom - 横幅将位于卡片组下方(默认)
  • UPCardsCarouselLabelBannerLocation_top - 横幅将位于卡片组上方

最后,您还可以通过labelBanner属性访问横幅视图对象,因此您可以自定义它。

许可证

The MIT License (MIT)

Copyright (c) 2014 Paul Ulric

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.