[翻译] 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:

之后,你需要设定代理以及给代理提供数据:

  • delegate object that conforms to the UPCardsCarouselDelegate protocol
  • dataSource object that conforms to the UPCardsCarouselDataSource protocol

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.

 

时间: 2024-11-08 22:03:35

[翻译] UPCardsCarousel的相关文章

[翻译]JDK 8 兼容性指南

翻译官方文档,删除部分可忽略. 译者:坤谷,井桐,激酶 兼容性是一个复杂的问题. 本文介绍了Java平台潜在的三种不兼容问题: 源码: 源码兼容性问题关注Java源代码转换成class文件是否兼容,包括代码是否仍然可编译. 二进制: 在Java语言规范中,二进制兼容性定义为:"类的改变是二进制兼容的(或者不破坏二进制兼容性),是指如果改变前的类的二进制在链接时没有错误,那么改变后的类在链接时仍然没有错误." 行为 : 行为兼容性包括在运行时执行的代码的语义. 欲了解更多信息,请参阅Op

java.security.Guard翻译

  Overview Package  Class Use Tree Deprecated Index Help JavaTM 2 PlatformStd. Ed. v1.4.2  PREV CLASS   NEXT CLASSFRAMES    NO FRAMES     All Classes SUMMARY: NESTED | FIELD | CONSTR | METHODDETAIL: FIELD | CONSTR | METHOD java.security Interface Gua

翻译CFSSL相关操作文档

我发现国内这个CFSSL资料蛮少的. 但如果深入到K8S认证之后,这块知识又必不可少. (OPENSSL也可实现,但好像不是主流) 于是花了两天快速翻译了一下几个文档. 贡献给有需要的同仁. 如有错误(肯定有!),欢迎提正. 百度网盘共享地址: https://pan.baidu.com/s/1skAQtAH

如何这段C#代码翻译成VB代码?谢谢!

问题描述 如何这段C#代码翻译成VB代码?谢谢! private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { //自动点击弹出确认或弹出提示 IHTMLDocument2 vDocument = (IHTMLDocument2)webBrowser1.Document.DomDocument; vDocument.parentWindow.execScrip

php-java和PHP有纯中文的官方手册吗?还是只有部分的翻译?

问题描述 java和PHP有纯中文的官方手册吗?还是只有部分的翻译? java和PHP有纯中文的官方手册吗?还是只有部分的翻译?我英文不好,能不能学呢? 解决方案 http://cn2.php.net/manual/zh/index.php 解决方案二: java的JDK有中文版的API,PHP网上也有中文手册.现在网络资源这么丰富,只有肯上心,学东西还是很容易的. 选定一个完整的视频教程,跟着练习,上手是很容易的. 我就是2010年暑假跟着传智播客视频教程自学的Java,现在已经很熟练了.祝好

傲游浏览器怎么翻译网页

  步骤一:没有傲游浏览器的童鞋 步骤二:点开下拉====勾选"翻译". 步骤三:输入你想要的翻译的网址,选定你想翻译的内容 步骤四:耐心等待翻译结果

Word 2010中的“翻译字典”

  1.打开一篇文字文档,并且里面与你有需要翻译的文字,例如,我们这里先选择一篇中文散文; 2.在功能区点击"审阅"选项卡,选择"语言"区域的"翻译"选项组,单击"翻译所选文字"; 3.单击"审阅"功能卡,点击"语言"区域的"翻译"选项组,在弹出的下拉菜单中选择"选择转换语言"; 4.此时窗口会弹出一个"翻译语言选项"的对话框,

Word每一页的左边显示英语右边显示中文翻译

  现在,您想实现的效果是,在每一页里面,左边是英文,右边是对应的翻译好的中文.像这样的排版方式,可以方便我们更好的学习英语. ①使用分栏的是不科学的 要解决这个问题,很多人第一时间就会想到分栏,想把英文放在栏的左边,中文放在栏的右边.然而,这是可行的,却是不科学的. 因为,使用Word里面的自动分栏,原文英文和翻译后的中文,很难一一对应,造成学习上的困难.另外,如果您想再排版实现一一对应,那么,难度是非常大. ②使用文本框也是不合理的 以上方法难以实现.很多人会想到使用文本框的办法. 即在Wo

360浏览器如何翻译英文网页

  整个网页翻译: 1.打开360浏览器,在浏览器中打开你想浏览的英文网站,选择浏览器上面的翻译三角符号. 2.选择第一项,翻译当前网页,就会开始翻译了. 3.翻译完后,就可以看到全部是中文了. 单个句子翻译: 1.同样选择浏览器上面的翻译,选择第二项翻译文字. 2.在弹出的翻译对话框中,将要翻译的英文复制到文本框中,点击下面的翻译. 3.翻译完后,翻译的结果就在下面了,很方便的.