Tocropviewcontroller: 如何创建原始的完成按钮

创建于 2019-07-27  ·  4评论  ·  资料来源: TimOliver/TOCropViewController

question

最有用的评论

@twinkalGSensussoft
您好,示例代码在这里。

  1. 创建原始的cropViewController。
let cropViewController = CropViewController(image: OriginalImage)
  1. 将cropViewController 添加到容器视图
self.addChild(cropViewController)
self.cropContainer.addSubview(cropViewController.view)
  1. 调整cropViewController 框架。
cropViewController.view.frame = CGRect(x: self.cropContainer.frame.origin.x, y: self.cropContainer.frame.origin.y, width: self.cropContainer.frame.width, height: self.cropContainer.frame.height)
  1. 如果要隐藏默认工具栏,则必须在代码下方。
cropViewController.toolbar.isHidden = true
  1. 显示cropViewController。
cropViewController.didMove(toParent: self)
  1. 定义原始完成操作并调用 doneButtonTapped!()。
<strong i="29">@IBAction</strong> func cropDoneButtonTUP(_ sender: UIButton) {       
      self.cropViewController.toolbar.doneButtonTapped!()
}

所有4条评论

我自己解决了这个问题。

你是怎么做到的? 你能在这里解释一下吗? @穆拉诺布

@twinkalGSensussoft
您好,示例代码在这里。

  1. 创建原始的cropViewController。
let cropViewController = CropViewController(image: OriginalImage)
  1. 将cropViewController 添加到容器视图
self.addChild(cropViewController)
self.cropContainer.addSubview(cropViewController.view)
  1. 调整cropViewController 框架。
cropViewController.view.frame = CGRect(x: self.cropContainer.frame.origin.x, y: self.cropContainer.frame.origin.y, width: self.cropContainer.frame.width, height: self.cropContainer.frame.height)
  1. 如果要隐藏默认工具栏,则必须在代码下方。
cropViewController.toolbar.isHidden = true
  1. 显示cropViewController。
cropViewController.didMove(toParent: self)
  1. 定义原始完成操作并调用 doneButtonTapped!()。
<strong i="29">@IBAction</strong> func cropDoneButtonTUP(_ sender: UIButton) {       
      self.cropViewController.toolbar.doneButtonTapped!()
}

如果我不想只旋转 90 度怎么办? 我想给它添加一个旋转手势,可以吗? 如果是,那么请帮助我。
提前致谢。

此页面是否有帮助?
0 / 5 - 0 等级

相关问题

agusguerra10 picture agusguerra10  ·  5评论

ojseven picture ojseven  ·  7评论

felipebonezi picture felipebonezi  ·  6评论

ClaesClaes picture ClaesClaes  ·  6评论

mugunth87 picture mugunth87  ·  5评论