Guest User

Untitled

a guest
Oct 20th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. //
  2. // RectangleDrawableView.swift
  3. // OpenCVTest
  4. //
  5. // Created by Aratech iOS on 1/8/17.
  6. // Copyright © 2017 Nicolas Landa. All rights reserved.
  7. //
  8.  
  9. import UIKit
  10.  
  11. class RectangleDrawableView: DrawableView {
  12.  
  13. override func update(path: inout UIBezierPath, with point: CGPoint) {
  14. let origin = self.startingPoint
  15. let height = point.y - origin.y
  16. let width = point.x - origin.x
  17. path = UIBezierPath(rect: CGRect(origin: origin, size: CGSize(width: width, height: height)))
  18. }
  19.  
  20. override func view(from pathComponents: [CGPoint]) -> UIView {
  21. var newPath = UIBezierPath()
  22. self.update(path: &newPath, with: pathComponents.last!)
  23. newPath.close()
  24.  
  25. let pathView = UIView(frame: CGRect(origin: newPath.bounds.origin, size: newPath.bounds.size))
  26. pathView.backgroundColor = .clear
  27. pathView.layer.borderWidth = self.pathLayer.lineWidth
  28. pathView.layer.borderColor = self.pathLayer.strokeColor
  29.  
  30. return pathView
  31. }
  32. }
Add Comment
Please, Sign In to add comment