[翻译] ZLSwipeableView

简介:

ZLSwipeableView

A simple view for building card like interface like Tinder and Potluck. ZLSwipeableView was originally developed for Murmur.

一个简单的view,效果类似于卡牌,ZLSwipeableView最初是用于Murmur应用的开发.

Preview

Swipe

Swipe Cancel

Swipe Programmatically

CocoaPods - 用CocoaPods安装

You can install ZLSwipeableView through CocoaPods adding the following to your Podfile:

你可以通过CocoaPods来安装这个文件:

pod 'ZLSwipeableView'

Usage - 使用

Check out the demo app for an example.

你可以在示例中查看使用方法.

ZLSwipeableView can be added to storyboard or instantiated programmatically:

ZLSwipebleView可以直接在storyboard中使用或者是直接实例化出来:

ZLSwipeableView *swipeableView = [[ZLSwipeableView alloc] initWithFrame:self.view.frame];
[self.view addSubview:swipeableView];

ZLSwipeableView must have an object that implements ZLSwipeableViewDataSource to act as a data source. ZLSwipeableView will prefetch three views in advance to animate them.

ZLSwipeableView必须有一个对象,这个对象是作为data source来使用的.

// required data source
self.swipeableView.dataSource = self;

#pragma mark - ZLSwipeableViewDataSource
- (UIView *)nextViewForSwipeableView:(ZLSwipeableView *)swipeableView {
  return [[UIView alloc] init];
}

The demo app includes examples of both creating views programmatically and loading views from Xib files that use Auto Layout.

ZLSwipeableView can have an optional delegate to receive callback.

demo中已经包含了通过Xib和普通模式创建出来view的例子,ZLSwipeableView能够通过可选的协议来接受回调.

// optional delegate
self.swipeableView.delegate = self;

#pragma mark - ZLSwipeableViewDelegate
- (void)swipeableView:(ZLSwipeableView *)swipeableView didSwipeLeft:(UIView *)view {
    NSLog(@"did swipe left"); } - (void)swipeableView:(ZLSwipeableView *)swipeableView didSwipeRight:(UIView *)view { NSLog(@"did swipe right"); } - (void)swipeableView:(ZLSwipeableView *)swipeableView didCancelSwipe:(UIView *)view { NSLog(@"did cancel swipe"); } - (void)swipeableView:(ZLSwipeableView *)swipeableView didStartSwipingView:(UIView *)view atLocation:(CGPoint)location { NSLog(@"did start swiping at location: x %f, y%f", location.x, location.y); } - (void)swipeableView:(ZLSwipeableView *)swipeableView swipingView:(UIView *)view atLocation:(CGPoint)location translation:(CGPoint)translation { NSLog(@"swiping at location: x %f, y %f, translation: x %f, y %f", location.x, location.y, translation.x, translation.y); } - (void)swipeableView:(ZLSwipeableView *)swipeableView didEndSwipingView:(UIView *)view atLocation:(CGPoint)location { NSLog(@"did start swiping at location: x %f, y%f", location.x, location.y); }

To swipe the top view programmatically:

滑动顶部的view:

[self.swipeableView swipeTopViewToLeft];
[self.swipeableView swipeTopViewToRight];

To discard all views and reload programmatically:

弃用所有的view,然后重新加载:

[self.swipeableView discardAllSwipeableViews];
[self.swipeableView loadNextSwipeableViewsIfNeeded];

Requirements - 需要的环境

  • iOS 7 or higher. iOS7及以上
  • Automatic Reference Counting (ARC). ARC

Credits

  • Thanks iamphill for adding new delegates.
  • Thanks mdznr for making the code style consistent.
  • Thanks coryalder for making dataSource and delegate IBOutlets.

 

目录
相关文章
php常见问题,php.ini文件不存在或者找不到,mb_strlen()函数未定义系列问题,dll模块找不到的解决
本文介绍了解决PHP常见问题的步骤,包括定位和创建`php.ini`文件,以及解决`mb_strlen()`函数未定义和DLL模块加载错误的具体方法。
php常见问题,php.ini文件不存在或者找不到,mb_strlen()函数未定义系列问题,dll模块找不到的解决
|
Kubernetes 安全 虚拟化
VMware Fusion 13.6.3 发布下载,现在完全免费无论个人还是商业用途
VMware Fusion 13.6.3 发布下载,现在完全免费无论个人还是商业用途
23920 10
VMware Fusion 13.6.3 发布下载,现在完全免费无论个人还是商业用途
|
存储 C语言
C enum(枚举)详解
在C语言中,`enum`(枚举类型)允许用户定义包含命名整数常量的数据类型,提高了代码的可读性和可维护性。通过关键字`enum`定义枚举,如`enum Color {RED, GREEN, BLUE}`。枚举值默认从0开始递增,也可自定义。枚举类型实际上是整型的别名,可用于简化代码并限制变量的具体取值范围。
882 15
|
消息中间件 机器学习/深度学习 人工智能
AI赋能运维:实现运维任务的智能化自动分配
AI赋能运维:实现运维任务的智能化自动分配
1186 24
|
机器学习/深度学习 计算机视觉
目标检测笔记(六):如何结合特定区域进行目标检测(基于OpenCV的人脸检测实例)
本文介绍了如何使用OpenCV进行特定区域的目标检测,包括人脸检测实例,展示了两种实现方法和相应的代码。
542 1
目标检测笔记(六):如何结合特定区域进行目标检测(基于OpenCV的人脸检测实例)
|
存储 NoSQL JavaScript
MongoDB存储过程实战:聚合框架、脚本、最佳实践,一文全掌握!
【8月更文挑战第24天】MongoDB是一款备受欢迎的文档型NoSQL数据库,以灵活的数据模型和强大功能著称。尽管其存储过程支持不如传统关系型数据库,本文深入探讨了MongoDB在此方面的最佳实践。包括利用聚合框架处理复杂业务逻辑、封装业务逻辑提高复用性、运用JavaScript脚本实现类似存储过程的功能以及考虑集成其他工具提升数据处理能力。通过示例代码展示如何创建订单处理集合并定义验证规则,虽未直接实现存储过程,但有效地演示了如何借助JavaScript脚本处理业务逻辑,为开发者提供更多实用指导。
353 2
|
Java Spring 容器
Spring6(二):IoC容器(4)
Spring6(二):IoC容器(4)
127 0
|
存储 小程序 API
uniapp项目实战第五章:小程序Pinia持久化
uniapp项目实战第五章:小程序Pinia持久化
1140 0
|
Linux
如何在Linux中挂起和恢复进程?
如何在Linux中挂起和恢复进程?
1240 1
|
运维 中间件 数据库