Skip to content

Instantly share code, notes, and snippets.

@stephancasas
Created March 4, 2024 23:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stephancasas/627aaab1c7f348f0fb64279569f07390 to your computer and use it in GitHub Desktop.
Save stephancasas/627aaab1c7f348f0fb64279569f07390 to your computer and use it in GitHub Desktop.
Quickly apply a 1-pixel debugging border to NSView instances.
extension NSView {
var debugBorder: NSColor? {
set {
guard let newValue = newValue else {
self.layer?.borderColor = nil;
self.layer?.borderWidth = 0;
return;
}
self.wantsLayer = true;
self.layer?.borderColor = newValue.cgColor;
self.layer?.borderWidth = 1;
}
get {
guard let color = self.layer?.borderColor else {
return nil;
}
return .init(cgColor: color)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment