Reditor 1.0.5

Reditor 1.0.5

Igor Makeev 维护。



Reditor 1.0.5

  • 作者
  • iOS Ninja

Reditor

CocoaPods CocoaPods

  • Reditor 允许通过绘制和放置文本来标注图像

Screenshot Screenshot

入门指南

使用CocoaPods安装

CocoaPods是为Swift和Objective-C Cocoa项目提供一个依赖管理器的工具。包含54,000多库,被超过3百万的应用所使用。CocoaPods可以帮助您优雅地扩展您的项目。

  1. 使用默认的Ruby安装可能需要在安装Ruby Gem时使用sudo权限。
$ sudo gem install cocoapods
  1. CocoaPods提供了一个pod init命令,用于创建包含明智默认值的Podfile。您应该使用它。
$ cd <#Your project path#>
$ pod init
  1. 然后将Reditor添加到Podfile中
platform :ios, '10.0'
use_frameworks!

target 'MyApp' do
    pod 'Reditor'
end
  1. 运行pod install命令
$ pod install

使用方法

初始化及设置

  • 注意:为了获得更好的外观效果,建议预先定义一个要包含reditor视图的视图容器。
  1. 在Storyboard中创建一个UIView,并将其连接到您自己的控制器的"@IBOutlet"。
  • (您也可以在代码中这样做。创建一个大小为"self.bounds"的UIView,并添加到透明度为零的子视图中。)
  1. Reditor初始化返回一个UIViewController,应该将其添加到您的子视图中。
  2. 然后为预定义容器中的reditorVC的视图分配框架大小。
  3. 将reditorVC的视图添加到预定义容器的子视图中。
  4. 向预定义容器添加透明度动画以实现淡入效果。
  5. 最后,添加协议和函数。
class ViewController: UIViewController, ReditorProtocol {


    @IBOutlet weak var reditorContainerView: UIView!


    func presentReditorVC(image: UIImage) {
    
        if let reditorVC = Reditor.setupRedior(withImage: image, listener: self) {
    
            self.addChildViewController(reditorVC)
    
            /** Container */
            reditorContainerView.alpha = 0.0
    
            /** Reditor config */
            reditorVC.view.frame = self.reditorContainerView.bounds
            reditorContainerView.addSubview(reditorVC.view)
    
            /** Appearance */
            UIView.animate(withDuration: 0.33) {
                self.reditorContainerView.alpha = 1.0
            }
        }else{
            print("Ooops!\nSomething went wrong")
        }
    }


    func reditorDidFinishedDrawing(image: UIImage) {
        UIView.animate(withDuration: 0.33, animations: {
            self.reditorContainerView.alpha = 0.0
        }, completion: { _ in
            for subview in self.reditorContainerView.subviews {
                subview.removeFromSuperview()
            }
        })
    }

    func reditorDidCanceledDrawing() {
        UIView.animate(withDuration: 0.33, animations: {
            self.reditorContainerView.alpha = 0.0
        }, completion: { _ in
            for subview in self.reditorContainerView.subviews {
                subview.removeFromSuperview()
            }
        })
    }

}