当前位置: 首页 > news >正文

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

MethodDescription
reloadDataReloads the carousel data and recreates the visible cards and moves to the top of the cards deck
reloadDataWithCurrentIndex:(NSUInteger)indexReloads the carousel data and recreates the visible cards and moves to the specified index in the cards deck
reloadNumberOfCardsReloads only the number of cards in the carousel and doesn't change the visible cards
reloadCardAtIndex:(NSUInteger)indexRecreates the card at the specified index
cardAtIndex:(NSUInteger)indexReturn 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.

 

相关文章:

  • Java编程的逻辑 (1) - 数据和变量
  • ABP源码分析三十二:ABP.SignalR
  • office2003 安装步骤及注意事项
  • 我的屌丝giser成长记-研一篇(下)
  • 本周活动
  • MapReduce的过程(2)
  • Android 双卡双待识别
  • 房坑
  • 该不该用inline-block取代float? inline和float的区别?
  • hibernate--联合主键--XML
  • 动态素组(ArrayList)
  • cssReset - css初始化
  • KeyMob移动广告聚合平台 开发者赚钱平台
  • Lua非常有用的工具——递归打印表数据
  • C风格字符串
  • ECS应用管理最佳实践
  • FastReport在线报表设计器工作原理
  • Java 23种设计模式 之单例模式 7种实现方式
  • Js实现点击查看全文(类似今日头条、知乎日报效果)
  • Mocha测试初探
  • MySQL QA
  • node-glob通配符
  • python docx文档转html页面
  • SpiderData 2019年2月23日 DApp数据排行榜
  • tweak 支持第三方库
  • vue从创建到完整的饿了么(18)购物车详细信息的展示与删除
  • Vue学习第二天
  • 机器人定位导航技术 激光SLAM与视觉SLAM谁更胜一筹?
  • 前端相关框架总和
  • 如何将自己的网站分享到QQ空间,微信,微博等等
  • 如何优雅的使用vue+Dcloud(Hbuild)开发混合app
  • 使用parted解决大于2T的磁盘分区
  • 推荐一款sublime text 3 支持JSX和es201x 代码格式化的插件
  • ​linux启动进程的方式
  • # 手柄编程_北通阿修罗3动手评:一款兼具功能、操控性的电竞手柄
  • # 再次尝试 连接失败_无线WiFi无法连接到网络怎么办【解决方法】
  • ( 10 )MySQL中的外键
  • (2009.11版)《网络管理员考试 考前冲刺预测卷及考点解析》复习重点
  • (27)4.8 习题课
  • (C++)栈的链式存储结构(出栈、入栈、判空、遍历、销毁)(数据结构与算法)
  • (SpringBoot)第七章:SpringBoot日志文件
  • (附源码)spring boot校园拼车微信小程序 毕业设计 091617
  • (含react-draggable库以及相关BUG如何解决)固定在左上方某盒子内(如按钮)添加可拖动功能,使用react hook语法实现
  • (力扣记录)1448. 统计二叉树中好节点的数目
  • (三)elasticsearch 源码之启动流程分析
  • .babyk勒索病毒解析:恶意更新如何威胁您的数据安全
  • .Net - 类的介绍
  • .net core使用ef 6
  • .NET/MSBuild 中的发布路径在哪里呢?如何在扩展编译的时候修改发布路径中的文件呢?
  • .netcore 如何获取系统中所有session_ASP.NET Core如何解决分布式Session一致性问题
  • .NET程序员迈向卓越的必由之路
  • .Net接口调试与案例
  • .NET文档生成工具ADB使用图文教程
  • :“Failed to access IIS metabase”解决方法
  • @FeignClient 调用另一个服务的test环境,实际上却调用了另一个环境testone的接口,这其中牵扯到k8s容器外容器内的问题,注册到eureka上的是容器外的旧版本...