PictureViewMaster 2.0

PictureViewMaster 2.0

测试已测试
语言语言 SwiftSwift
许可证 Apache 2
发布最后发布2016 年 9 月
SPM支持 SPM

Andres Gerace 维护。




交互式图像投影仪。

This library supports Swift 2.3
Swift 2.3 is currently in branch master.

摘要

这是一个库,它提供了一个具有放大其图片能力的 UIImageView 子类,用户可以旋转、拖动和缩放它。

如何使用它?

不要使用常规的 UIImageView 对象,请使用 PictureMasterImageView。它们将自动添加一个手势识别器,以便用户在触摸时会通知其 delegate。然后,在 delegate 回调中,通过实例化一个对象并给它传递 UIImage 和/或要支持的手势(默认全部支持)来实现 PictureMasterViewController。它将在您的当前视图内创建一个包含大图像和所有手势识别器以及消失功能的视图。注意:PictureMasterImageView 不是必须的。您可以将所需的 UIImage 直接传递给 PictureMasterViewController,它也会正常工作。UIImage 子类是为了有一个便捷的方法来创建可点击和可放大的 UIImageView。

安装

将这些文件拖到您的项目中: PictureMasterViewController.xibPictureMasterViewController.swiftPictureMasterImageView.swift,您就可以开始了。或者您可以使用 CocoaPods。

pod 'PictureMasterView'

然后导入库

import PictureMasterView

用法

//Create an PictureMasterImageView object and assign its delegate
let sampleImage : PictureMasterImageView = PictureMasterImageView(image: UIImage(named:"sampleImage"), andDelegate:self)
//Or just add it on the interface builder, add a reference and assign a the delegate
self.ibSampleImage.delegate = self

//Then conform the the PictureMasterImageViewDelegate
func pictureMasterImageViewDidReceiveTap (pictureMasterImageView: PictureMasterImageView) {
let masterViewController: PictureMasterViewController = PictureMasterViewController(nibName: "PictureMasterViewController", bundle: nil)
// Initialized with custom gestures
masterViewController.showImage(pictureMasterImageView.image!, inViewController:self, withGestures: [.Rotate, .Zoom, .Drag])
// Initialized with all gestures enabled
masterViewController.showImage(pictureMasterImageView.image!, inViewController:self)
}

就这样。PictureMasterView 将负责显示自己,并自己消失,因为我们都是懒惰的程序员...

旧版本支持

  • 从其 2.0 版本开始,该库与 Swift 3.0 兼容。
  • 如果您需要旧语言版本的支持,请查看:
  • 1.1 版本支持 Swift 2.3。
  • 1.0 版本支持 Swift 2.2。

联系我们

对于有关使用此库的 问题常规评论,请使用我们的公共 hipchat 房间

如果您在使用这个库时发现任何 错误 或遇到 问题,请在这个仓库打开一个问题(或发起一个拉取请求 :))。

您可以在inaka.github.io查看我们所有的开源项目。