[翻译] UPCardsCarousel
UPCardsCarousel

UPCardsCarousel is a carousel with a cards based UI for iOS.
UPCardsCarousel是一个旋转木马效果的UI控件.
UPCardsCarousel

Requirements
UPCardsCarousel uses ARC and requires iOS 7.0+.
需要ARC,iSO7.0以上.
Works for iPhone.
只针对iPhone开发.
Installation
CocoaPods
UPCardsCarousel is available through CocoaPods. To install it, simply add the following line to your Podfile:
你可以通过 CocoaPods 来安装.执行以下一段话即可.
pod "UPCardsCarousel"
Manual
Simply copy the folder UPCardsCarousel to your project and import it in XCode.
你只需要将UPCardsCarousel文件夹复制到你的项目中即可.
Usage
Start by importing the header file:
一开始,先引入头文件:
#import "UPCardsCarousel.h"
Now, you can create a UPCardsCarousel object by giving it a frame:
然后,你可以创建出UPCardsCarousel实体,然后给定一个frame值:
UPCardsCarousel *carousel = [[UPCardsCarousel alloc] initWithFrame:aFrame];
Then you need to assign to it:
之后,你需要设定代理以及给代理提供数据:
- a
delegateobject that conforms to theUPCardsCarouselDelegateprotocol - a
dataSourceobject that conforms to theUPCardsCarouselDataSourceprotocol
Data Source
The data source informs the carousel about the total number of cards and the content of each card through two self-explanatory methods:
数据源是给carousel提供有多少张卡片,以及每张图片上面的内容:
- (NSUInteger)numberOfCardsInCarousel:(UPCardsCarousel *)carousel(required)- (UIView *)carousel:(UPCardsCarousel *)carousel viewForCardAtIndex:(NSUInteger)index(required)
The labels in the banner are given with an optional method. If the data source doesn't implement this method, the label banner will not be displayed.
以下方法是可选方法,用来给卡片提供标题的,如果没有实现,默认是不会显示出来的.
- (NSString *)carousel:(UPCardsCarousel *)carousel labelForCardAtIndex:(NSUInteger)index(optional)
Delegate
The delegate is optional and will be notified when some events occur:
代理方法是非必须的,用以提示事件发生的时机:
- (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
Methods
| Method | Description |
|---|---|
| reloadData | Reloads the carousel data and recreates the visible cards and moves to the top of the cards deck |
| reloadDataWithCurrentIndex:(NSUInteger)index | Reloads the carousel data and recreates the visible cards and moves to the specified index in the cards deck |
| reloadNumberOfCards | Reloads only the number of cards in the carousel and doesn't change the visible cards |
| reloadCardAtIndex:(NSUInteger)index | Recreates the card at the specified index |
| cardAtIndex:(NSUInteger)index | Return the card view at the specified index |
Customization
Cards Deck
Usually, the carousel will not display all the cards supplied by the data source at once. It will handle a infinite scrolling process by destroying and creating cards at both ends. The number of visible cards is given and can be customized through the following property:
通常情况下,carousel不会一下子显示出所有的图片.他有重用机制,并支持无限滑滚.可见的卡片数由以下方法提供:
maxVisibleCardsCount(default is 6)
You can customize the duration of the card movement between the hidden deck and the visible deck, with this property:
你可以定制每张卡片的移动时间,默认是0.4秒:
movingAnimationDuration(defaut is 0.4 seconds)
By default, the carousel will return to the top of the deck when making a double-tap on the first hidden card.
默认情况下,双击carousel会返回第一张显示的图片.

You can disable this behaviour by setting the doubleTapToTop property to NO.
你可以禁用双击功能.
Labels Banner
You can customize the text font and color of the banner through these two methods:
你可以通过以下两个方法来定制横幅:
- (void)setLabelFont:(UIFont *)font(default is system font)- (void)setLabelTextColor:(UIColor*)color(default is[UIColor blackColor])
You can choose between two locations for the banner through the labelBannerPosition property:
你可以通过labelBannerPosition属性来设置位移值:
UPCardsCarouselLabelBannerLocation_bottom- the banner will be located below the cards deck (default)UPCardsCarouselLabelBannerLocation_top- the banner will be located above the cards deck
Finally, you also have access to the banner view object through the labelBanner property so you can customize it as you want.
当然,你也可以写你自己的横幅view.给labelBanner赋值即可.
License
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.
[翻译] UPCardsCarousel的更多相关文章
- 《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 ...
随机推荐
- 解决MySQL联表时出现字符集不一样
mysql 建表时都会设置表的字符集和排序规则,通常是 utf8,不过我这边习惯建表的字符集是 utf8mb4,排序规则是 utf8mb4_unicode_ci.有些 utf8mb4 的表默认排序规则 ...
- mysql修改存储过程的权限
直接上代码 grant execute on procedure 表名.存储过程名(eg: student.find) to '用户名'@'host'(eg: 'volumelicense'@'%') ...
- mysql创建用户,并指定用户的权限(grant命令)
参考链接http://blog.csdn.net/leili0806/article/details/8573636,谢谢这位仁兄 1.创建新用户的SQL语句: CREATE USER 'pig'@' ...
- JAVA 图像操作辅助类
package util; import java.awt.Component; import java.awt.Image; import java.awt.MediaTracker; import ...
- win10装系统--笔记
U盘安装WIN10时显示 windows无法安装到这个磁盘 选中的磁盘采用GPT分区形式 一.原因分析 win8/win10系统均添加快速启动功能,预装的win8/win10电脑默认都是UEFI引导和 ...
- I/O模式总结
进程读取数据时要经过两个阶段: 1.等待内核准备数据: 2.将内核缓冲区中的数据复制到进程缓冲区中. 一.阻塞IO 进程会阻塞在等待内核准备数据和数据从内核空间复制到用户空间这两个阶段. 二.非阻塞I ...
- Qt Model View 框架
Model-View及Qt实现 Model-View-Controller架构最早出现在SmallTalk语言中,至今出现了很多变体. Model是负责维护数据(如管理数据库),View负责显示与用户 ...
- 我用ASP.NET缓存之数据缓存
[我的理解] Cache,是内置的对象集合.是全局的,类似于static Arraylist.它是线程安全的,添加或修改Cache中的项目时,不需要锁定或者解除Cache. 添加 Cache[Key] ...
- SpingMVC_注解式开发_接收请求参数
一.逐个接收 import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotat ...
- git fork后提交pull request到原作者,别人的pull request我们要怎样merge融合
首先要记住,pull request 不是随便提交的,这是建立在你对原作者的项目有fork,并对项目中的代码有修改,并提交到了你的GitHub上,才能进行下面的操作. 若不知怎样fork项目,请看我的 ...