Skip to content

Instantly share code, notes, and snippets.

@onmyway133
Last active July 5, 2018 11:15
Show Gist options
  • Save onmyway133/b004dce4298822e631432f29caf52c64 to your computer and use it in GitHub Desktop.
Save onmyway133/b004dce4298822e631432f29caf52c64 to your computer and use it in GitHub Desktop.
private func drawBox(overlayLayer: CALayer, normalisedRect: CGRect) {
let x = normalisedRect.origin.x * overlayLayer.frame.size.width
let y = normalisedRect.origin.y * overlayLayer.frame.size.height
let width = normalisedRect.width * overlayLayer.frame.size.width
let height = normalisedRect.height * overlayLayer.frame.size.height
let outline = CALayer()
outline.frame = CGRect(x: x, y: y, width: width, height: height).scaleUp(scaleUp: 0.1)
outline.borderWidth = 2.0
outline.borderColor = UIColor.red.cgColor
overlayLayer.addSublayer(outline)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment