Home

NSView

NSView is the foundational view class in macOS AppKit. It represents a rectangular region within a window, and it is responsible for drawing content, handling user input, and managing a hierarchy of subviews. NSView is a subclass of NSResponder, placing it in the macOS responder chain where it receives mouse, keyboard, and drag-and-drop events.

A view has a frame in its superview’s coordinate system and a bounds rectangle that describes its

Coordinate systems in NSView are configurable. By default, the origin is at the bottom-left, but a view

NSView supports layout and geometry management through the view hierarchy. It can have subviews and a superview,

Rendering performance can be enhanced by enabling layer-backed views via the wantsLayer property, which causes a

Developers commonly subclass NSView to implement custom drawing, hit-testing, or interaction behavior. NSView remains a core

own
coordinate
space.
Subviews
are
drawn
in
back-to-front
order,
and
drawing
is
performed
by
overriding
the
drawRect:
method
or
drawing
with
layer-backed
content.
A
view
can
be
marked
for
redisplay
using
setNeedsDisplay:,
prompting
the
system
to
redraw
during
the
next
update
cycle.
can
override
isFlipped
to
return
true
to
adopt
a
top-left
origin,
which
aligns
with
many
modern
UI
layouts.
and
provides
methods
to
convert
coordinates
between
views.
It
also
participates
in
Auto
Layout,
with
constraints
used
to
define
positions
and
sizes
relative
to
other
views.
CALayer
to
back
the
view.
This
enables
hardware-accelerated
compositing
and
animations,
while
preserving
the
view’s
drawing
and
event-handling
responsibilities.
building
block
for
macOS
interfaces,
even
as
newer
UI
paradigms
and
SwiftUI
evolve.