Skip to content

Commit

Permalink
Add a circle hole and a square frame around it
Browse files Browse the repository at this point in the history
  • Loading branch information
pinarol committed Dec 12, 2024
1 parent 2c54ae0 commit 8ca0f8a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Sources/GravatarUI/ImageCropper/CropFrameOverlayView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,18 @@ class CropFrameOverlayView: UIView {
context.setFillColor(UIColor.black.withAlphaComponent(0.5).cgColor)
context.fill(rect)

// Clear the scrollView's area to make it transparent
// Create a circular path for the transparent hole
let circlePath = UIBezierPath(ovalIn: scrollViewFrame)

// Clear the circular area
context.addPath(circlePath.cgPath)
context.clip(using: .evenOdd)
context.clear(scrollViewFrame)

// Draw a border around the crop frame
// Restore context to draw the square border
context.resetClip()

// Draw a white border around the square
context.setStrokeColor(UIColor.white.cgColor)
context.setLineWidth(1)
context.stroke(scrollViewFrame)
Expand Down

0 comments on commit 8ca0f8a

Please sign in to comment.