<!--
{
  "availability" : [
    "macOS: 10.0.0 - 27.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSImage/unlockFocus()",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSImage(im)unlockFocus"
  },
  "title" : "unlockFocus()"
}
-->

# unlockFocus()

Removes the focus from the image.

```
func unlockFocus()
```

## Discussion

This message must be sent after a successful [`lockFocus()`](/documentation/AppKit/NSImage/lockFocus()) or [`lockFocusOnRepresentation:`](/documentation/AppKit/NSImage/lockFocusOnRepresentation:) message and the completion of any intermediate drawing commands. This method restores the focus to the previous owner, if any.

Do not send this message if the preceding call to lock focus raised an `NSImageCacheException`.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)