AppKit 概览
文章目录
- AppKit 概览
- AppKit 简介
- 相关主题
- 一、Essentials
- 1、Protecting the User’s Privacy 保护用户隐私
- 2、Porting Your macOS Apps to Apple Silicon将 macOS 应用移植到 Apple Silicon 芯片。
- 二、 App 架构(App Structure)
- 1、 App and Environment
- Life Cycle 生命周期
- Environment 环境
- Handoff
- App Services
- App Help
- Errors
- 2、文档、数据和剪贴板 Documents, Data, and Pasteboard
- Documents
- User Preferences
- Pasteboard
- File Promises
- Object Editing
- 3、Cocoa 绑定 Cocoa Bindings
- Core Controllers
- Tree-Based Data
- Array-Based Data
- Key-Value Data
- Data Placeholders
- 4、资源管理 Resource Management
- Storyboard 故事版
- Assets 资源
- Nib Files
- 5、App 扩展 App Extensions
- Extension Support
- Quick Actions
- 三、用户界面(User Interface)
- 1、视图和控制 Views and Controls
- View Fundamentals 基础视图
- Container Views 容器视图
- Content Views 内容视图
- Controls 控件
- View Layout 视图布局
- Visual Adornments 视觉装饰
- UI Validation
- Tool Tips
- 2、视图管理 View Management
- Content Controllers 内容控制器
- Split View Interface 分离试图界面
- Stack View Interface
- Tab View Interface
- Paged Interface 分页界面
- Media Library Interface 媒体库界面
- 3、视图布局 View Layout
- Stack View
- Auto Layout Constraints
- Layout Guides
- Anchors
- 4、自定义主题Appearance Customization
- Dark Mode 黑暗模式
- Appearance System
- 5、动画 Animation
- View-Based Animations 基于View 的动画
- Presentations 显示
- Custom Animations 自定义动画
- 6、Windows, Panels, and Screens 窗口、面板和屏幕
- Windows 窗口
- Window Restoration
- Screens 屏幕
- Popovers 弹窗
- Alerts 提示
- Open and Save Panels 打开/保存面板
- Print and PDF Panels 打印和PDF面板
- Color Panels
- Font Panels
- 7、Sound, Speech, and Haptics 声音、演讲和触觉
- Sounds 声音
- Speech 语音
- Haptics 触控
- 8、语言国际化 Localizing Your App
- 9、Supporting Continuity Camera in Your Mac App 支持连续摄像
- 四、用户交互(User Interactions)
- 1 鼠标、键盘和触控板输入等事件 Mouse, Keyboard, and Trackpad
- Responder Objects
- Mouse, Keyboard, and Touch Events
- Trackpad
- Constants
- 2 Menus, Cursors, and the Dock 目录、光标和 Dock
- Menus
- Menu Validation
- Menu Bar Items
- Cursors 光标
- The Dock
- 3 手势 Gestures
- Standard Gestures
- Custom Gestures
- 4、 触控条 Touch Bar
- Essentials
- Touch Bar Items
- Scrubber Items
- Scrubber Layouts
- 5、拖放 Drag and Drop
- Drag Sources
- Drop Targets
- 6、macOS 辅助功能 Accessibility for macOS
- Essentials
- AppKit Elements
- Custom Elements
- Accessibility Types
- Convenience Functions
- Deprecated
- 五、Graphics, Drawing, Color, and Printing
- 1、图片和 PDF Images and PDF
- Images 图片
- Bitmap Formats 位图格式
- Vector Formats 矢量格式
- Custom Formats 自定义格式
- 2、画图 Drawing
- Drawing Contexts
- Shapes and Paths
- Strings
- Gradients
- Shadows
- OpenGL
- 3、颜色 Color
- Colors
- Color Selection
- Color Sampler
- 4、打印 Printing
- Print Panels
- Print Information
- 六、Text
- 1、 文字展示 Text Display
- Text Views
- Text Checking
- Spell Checker
- 2、TextKit
- Data Management 数据管理
- Layout 布局
- Formatted Content 格式化内容
- Attachments 附件
- Glyphs 符号
- Input Management 输入管理
- 3、字体 Fonts
- Font Data
- Management
- 三、其它
- 过期 Deprecated
转载自:/documentation/appkit
AppKit 简介
AppKit 用于构建和管理图形化的、事件驱动的 macOS 用户界面。
AppKit 包含 实现 macOS app 用户界面的所有对象,如 窗口,面板,按钮,目录,滚动条,输入框;它管理了所有展示在屏幕上的细节,与硬件设备和屏幕缓冲区通信,在绘制之前清理屏幕,并剪辑视图。
相关主题
一、Essentials
1、Protecting the User’s Privacy 保护用户隐私
/documentation/uikit/protecting_the_user_s_privacy
加密用户数据,尊重用户 使用数据的偏好。
2、Porting Your macOS Apps to Apple Silicon将 macOS 应用移植到 Apple Silicon 芯片。
/documentation/xcode/porting_your_macos_apps_to_apple_silicon
创建macOS应用,使其既可以在基于 Apple silicon 芯片的Mac 上运行,也可以在基于 Intel 的Mac 上运行。
二、 App 架构(App Structure)
1、 App and Environment
/documentation/appkit/app_and_environment
了解和系统交互的对象。
相关类、结构体和协议
Life Cycle 生命周期
-
class NSApplication 管理 app主事件循环 和 app使用到的所有资源。
- protocol NSApplicationDelegate NSApplication 可以执行的代理
- class NSRunningApplication 操作和提供信息 给一个app实例
Environment 环境
- class NSWorkspace 一个启动其它应用、执行各种文件处理服务 的工作区
- class 打开URL 或 启动应用程序时 使用的配置选项。
- struct NSAppKitVersion 决定Appkit 可用的版本常量
Handoff
- class NSUserActivity 应用在某一刻状态 的表示。
- protocol NSUserActivityRestoring
App Services
- class NSSharingService 一个让用户和其他服务共享内容的服务;其它服务 如 社交媒体服务 或者 app(如 mail 和 Safari)
- class NSSharingServicePicker 用户可以选择的一列分享服务列表。
- protocol NSSharingServicePickerDelegate 一组方法,可以用来自定义服务选择器行为
- class NSServicesMenuRequestor A set of methods that support interaction with items users can share through a sharing service. 一组方法,用来支持 用户通过一个共享服务来共享 的交互。
- class NSSharingServicePickerToolbarItem
- protocol NSSharingServicePickerToolbarItemDelegate
- protocol NSCloudSharingServiceDelegate iCloud 共享服务 执行这个协议, 来处理状态变化和错误。
Services Functions
App Help
- class NSHelpManager 用来展示在线帮助的对象。
- protocol NSUserInterfaceItemSearching 一组方法,app 可以用来为 自定义的服务数据 提供 Spotlight 支持。
Errors
AppKit Errors
AppKit 中的错误常量,由 NSAttributedString
生成。
2、文档、数据和剪贴板 Documents, Data, and Pasteboard
/documentation/appkit/documents_data_and_pasteboard
组织应用的数据和偏好设置,和 iCloud 中的剪切板共享数据。
Documents
Developing a Document-Based App Write an app that creates, manages, edits, and saves text documents.
- class NSDocument 定义 macOS 文档接口的抽象类
- class NSDocumentController 管理 app 文档的对象。
- class NSPersistentDocument 可以和 Core Data 集成的文档对象。
User Preferences
- class NSUserDefaultsController 一个可以从用户偏好设置数据库,访问用户偏好设置信息的控制器。继承自 NSController。
- class NSUbiquitousKeyValueStore 一个基于 iCloud 的键值对容器,你可以用来在 在 你的运行中 apps 之间共享数据。
Pasteboard
- class NSPasteboard 一个在 剪贴板服务 转换和获取数据的对象。
- class NSPasteboardItem 剪贴板上的一个对象。
- protocol NSPasteboardReading 从剪贴板初始化对象 的 一组方法。
- protocol NSPasteboardWriting 一组方法,定义了 获取可以被写入剪贴板的对象 的表示形式 的接口。
- protocol NSPasteboardItemDataProvider 剪贴板对象的数据提供者 使用的一组方法,用来提供数据给特定的 UTI 类型。
- struct 准备剪贴板的选项。
- protocol NSPasteboardTypeOwner
File Promises
支持基于 UTI 的拖放功能,包括drag flocking。若有可能,他们符合剪贴板 和 文件协调。
- {} Supporting Drag and Drop Through File Promises 获取和提供文件承诺,支持拖拽应用文件 和 剪贴板操作。
- {} Supporting Table View Drag and Drop Through File Promises Share data between macOS apps during drag and drop by using an item provider. 使用提供的 item 在 macOS 应用之间拖放时共享数据。
- {} Supporting Collection View Drag and Drop Through File Promises Share data between macOS apps during drag and drop by using an item provider.
- class NSFilePromiseProvider An object that provides a promise for the pasteboard.
- protocol NSFilePromiseProviderDelegate A set of methods that provides the name of the promised file and writes the file to the destination directory when the file promise is fulfilled.
- class NSFilePromiseReceiver An object that receives a file promise from the pasteboard.
Object Editing
- NSEditor
- NSEditorRegistration
3、Cocoa 绑定 Cocoa Bindings
/documentation/appkit/cocoa_bindings
使用 Cocoa Bindings 自动同步 数据模型和用户界面。
Core Controllers
- class NSObjectController A controller that can manage an object’s properties referenced by key-value paths.
- class NSController An abstract class that implements the NSEditor and NSEditorRegistration informal protocols required for controller classes.
Tree-Based Data
- Navigating Hierarchical Data Using Outline and Split Views Build a structured user interface that simplifies navigation in your app.
- class NSTreeController A bindings-compatible controller that manages a tree of objects.
- class NSTreeNode A node in a tree of nodes.
Array-Based Data
- class NSArrayController A bindings-compatible controller that manages a collection of objects.
Key-Value Data
- class NSDictionaryController A bindings-compatible controller that manages the display and editing of a dictionary of key-value pairs.
- class NSDictionaryControllerKeyValuePair A set of methods implemented by arranged objects to give access to information about those objects.
- NSKeyValueBindingCreation A set of methods that you can use to create and remove bindings between view objects and controllers, or between controllers and model objects.
Data Placeholders
- class NSBindingSelectionMarker NSPlaceholders A set of methods that an object can implement to register default placeholders to be displayed for a binding, when no other placeholder is specified.
4、资源管理 Resource Management
/documentation/appkit/resource_management
管理 storyboards 和 nib 文件,了解如何加载 资源文件夹中 存储的资源。
Storyboard 故事版
- class NSStoryboard An encapsulation of the design-time view controller and window controller graph represented in an Interface Builder storyboard resource file.
- class NSStoryboardSegue A transition or containment relationship between two scenes in a storyboard.
- class NSSeguePerforming A set of methods that support the mediation of a custom segue.
Assets 资源
- class NSDataAsset An object from a data set type stored in an asset catalog.
Nib Files
- class NSNib An object wrapper, or container, for an Interface Builder nib file.
5、App 扩展 App Extensions
/documentation/appkit/app_extensions
将你的app 的基本功能拓展到系统的其他部分。
Extension Support
- class NSExtensionContext The host app context from which an app extension is invoked.
- class NSExtensionRequestHandling The interface an app extension uses to respond to a request from a host app.
Quick Actions
Quick Actions allow your app extension to appear in the Finder Preview pane, Quick Actions menu, and Touch Bar.
- Add Functionality to Finder with Action Extensions Implement Action Extensions to provide quick access to commonly used features of your app.
- property list key NSExtensionServiceAllowsFinderPreviewItem A Boolean value indicating whether the extension appears in the Finder Preview pane and Quick Actions menu.
- property list key NSExtensionServiceFinderPreviewLabel A name for display when the extension appears in the Finder Preview pane and Quick Actions menu.
- property list key NSExtensionServiceFinderPreviewIconName The name of an icon for display when the extension appears in the Finder Preview pane and Quick Actions menu.
- property list key NSExtensionServiceAllowsTouchBarItem A Boolean value indicating whether the extension appears as a Quick Action in the Touch Bar.
- property list key NSExtensionServiceTouchBarLabel A name for display when the extension appears as a Quick Action in the Touch Bar.
- property list key NSExtensionServiceTouchBarIconName The name of an icon for display when the extension appears as a Quick Action in the Touch Bar
- property list key NSExtensionServiceTouchBarBezelColorName The color to use for the bezel around the extension when it appears as a Quick Action in the Touch Bar.
三、用户界面(User Interface)
让你的应用的用户界面 提供可视、可听、触控反馈给用户,让用户了解到app 正在处理什么。
1、视图和控制 Views and Controls
/documentation/appkit/views_and_controls
在屏幕上显示内容,定义 与这部分内容 允许的交互。
View Fundamentals 基础视图
- class NSView app 中绘制、打印 和 处理事件的基础。
- class NSControl 控件基本行为的定义,这些控件是专门的视图,通过使用 目标动作设计模式 将相关事件通知给应用。
- NSCell 在视图对象中 显示文字或图片的机制,无需使用完整的 NSView 子类开销。
- NSActionCell 控件中的激活区域。
Container Views 容器视图
使用容器视图 来在你的界面中 组织视图,促进这些视图之间的导航。
-
{} Localization-Friendly Layouts in macOS 这些工程展示本地化优化的自动布局约束,使用
NSGridView
作为容器来达成本地化布局。 - Grid View 将视图组织在一个弹性的网格中,并处理与这些试图关联的布局。
- NSSplitView 在一个横向或纵向的线性栈里,管理两个或更多视图的视图。
- {} Organize Your User Interface with a Stack View 将应用程序用户界面中的各个视图分组为可滚动的堆栈视图。
- NSStackView 一个在水平或垂直方向排列一组视图的 视图,在窗口大小更改时更新他们的位置和大小。
- NSTabView 一个包含多页界面的视图,一次显示一页。
Scroll View Provide an interface for navigating content that is too large to fit in the available space.
Content Views 内容视图
Use content views to organize and display your app’s data.
- Browser View Provide a column-based interface for viewing and navigating hierarchical information.
- Collection View Display one or more subviews in a highly configurable arrangement.
- Outline View Display a list-based interface for hierarchical data, where each level of hierarchy is indented from the previous one.
- Table View Display custom data in rows and columns.
- NSTextView A view that draws text and handles user interactions with that text.
- NSOpenGLView A view that displays OpenGL content in a view.
Deprecated
Controls 控件
Use controls to handle specific types of user interactions. Controls are specialized views that use the target-action design pattern to notify your app of interactions with their content.
- class NSButton 在屏幕上定义可用于触发操作的区域的控件。同比 UIButton。
- NSColorWell A control that displays a color value and lets the user change that color value.
- Date Picker Display a calendar date and provide controls for editing the date value.
- NSImageView A display of image data from an NSImage object in a frame.
- NSLevelIndicator A visual representation of a level or quantity, using discrete values.
- Path Control A display of a file system path or virtual path information.
- NSPopUpButton A control for selecting an item from a list.
- NSProgressIndicator An interface that provides visual feedback to the user about the status of an ongoing task.
- NSRuleEditor An interface for configuring a rule-based list of options.
- NSPredicateEditor A defined set of rules that allows the editing of predicate objects.
- Search Field Provide a text field that is optimized for text-based search interfaces.
- NSSegmentedControl Display one or more buttons in a single horizontal group.
- Slider Display a range of values from which the user selects a single value.
- NSStepper An interface with up and down arrow buttons for incrementing or decrementing a value.
- Text Field Provide a simple interface for displaying and editing text, including support for password fields and secure forms of text entry.
- Token Field Provide a text field whose text can be rendered in a visually distinct way so that users can recognize portions more easily.
- Toolbar Provide a space for controls under a window’s title bar and above your custom content.
- Combo Box Display a list of values in a pop-up menu that lets the user select a value or type in a custom value.
- NSMatrix A legacy interface for grouping radio buttons or other types of cells together.
- NSSwitch A control that offers a binary choice.
View Layout 视图布局
- protocol NSUserInterfaceCompression A protocol that describes how a UI control should redisplay when space is restricted.
Visual Adornments 视觉装饰
Add purely decorative elements to your user interface.
- NSVisualEffectView A view that adds translucency and vibrancy effects to the views in your interface.
- NSBox A stylized rectangular box with an optional title.
UI Validation
- protocol NSUserInterfaceValidations A protocol that a custom class can adopt to manage the enabled state of a UI element.
- protocol NSValidatedUserInterfaceItem A protocol that a custom class can adopt to manage the automatic enablement of a UI control.
Tool Tips
- NSViewToolTipOwner A set of methods for dynamically associating a tool tip with a view.
2、视图管理 View Management
/documentation/appkit/view_management
管理你的用户界面,包含 在窗口中,视图的尺寸和位置。
Content Controllers 内容控制器
- NSWindowController A controller that manages a window, usually a window stored in a nib file.
- NSViewController A controller that manages a view, typically loaded from a nib file.
- NSTitlebarAccessoryViewController An object that manages a custom view—known as an accessory view—in the title bar–toolbar area of a window.
Split View Interface 分离试图界面
- NSSplitViewController An object that manages an array of adjacent child views, and has a split view object for managing dividers between those views.
- NSSplitView A view that arranges two or more views in a linear stack running horizontally or vertically.
- NSSplitViewItem An item in a split view controller.
Stack View Interface
- NSStackView A view that arranges an array of views horizontally or vertically and updates their placement and sizing when the window size changes.
Tab View Interface
- NSTabViewController A container view controller that manages a tab view interface, which organizes multiple pages of content but displays only one page at a time.
- NSTabView A multipage interface that displays one page at a time.
- NSTabViewItem An item in a tab view.
Paged Interface 分页界面
- NSPageController An object that controls swipe navigation and animations between views or view content.
Media Library Interface 媒体库界面
- NSMediaLibraryBrowserController An object that configures and displays a Media Library Browser panel.
3、视图布局 View Layout
/documentation/appkit/view_layout
使用 栈视图 或 自动布局 来设置视图的位置和尺寸。
Stack View
- NSStackView A view that arranges an array of views horizontally or vertically and updates their placement and sizing when the window size changes.
Auto Layout Constraints
- NSLayoutConstraint The relationship between two user interface objects that must be satisfied by the constraint-based layout system.
Layout Guides
- NSLayoutGuide A rectangular area that can interact with Auto Layout.
- NSLayoutDimension A factory class for creating size-based layout constraint objects using a fluent API.
Anchors
- NSLayoutAnchor A factory class for creating layout constraint objects using a fluent API.
- NSLayoutXAxisAnchor A factory class for creating horizontal layout constraint objects using a fluent API.
- NSLayoutYAxisAnchor A factory class for creating vertical layout constraint objects using a fluent API.
4、自定义主题Appearance Customization
/documentation/appkit/appearance_customization
给应用添加 黑暗模式支持,使用 appearance 协议来调整你的 UI。
Dark Mode 黑暗模式
Supporting Dark Mode in Your Interface Update colors, images, and behaviors so that your app adapts automatically when Dark Mode is active.
Appearance System
Apply standard themes to the views in your interface.
- NSAppearance An object that manages standard appearance attributes for UI elements in an app.
- NSAppearanceCustomization A set of methods for getting and setting the appearance attributes of a view.
5、动画 Animation
/documentation/appkit/animation
对视图和其他内容 增加动画效果,给用户创造更吸引人的体验。
View-Based Animations 基于View 的动画
- NSViewAnimation An animation of an app’s views, limited to changes in frame location and size, and to fade-in and fade-out effects.
- NSAnimatablePropertyContainer A set of methods that defines a way to add animation to an existing class with a minimum of API impact.
- NSAnimationContext An animation context, which contains information about environment and state.
typealias The animation progress, as a floating-point number between 0.0
and 1.0
.
- enum NSAnimationEffect The type for standard system animation effects, which include both display and sound.
Presentations 显示
- NSViewControllerPresentationAnimator A set of methods that let you define animations to play when transitioning between two view controllers.
Custom Animations 自定义动画
- NSAnimation An object that manages the timing and progress of animations in the user interface.
- protocol NSAnimationDelegate A set of optional methods implemented by delegates of NSAnimation objects.
6、Windows, Panels, and Screens 窗口、面板和屏幕
/documentation/appkit/windows_panels_and_screens
整理视图层次结构,方便其在屏幕上显示。
Windows 窗口
- class NSWindow 应用程序在屏幕上显示的窗口。
- class NSPanel A special kind of window that typically performs a function that is auxiliary to the main window.
- protocol NSWindowDelegate A set of optional methods that a delegate of NSWindow can implement to respond to events, such as window resizing, moving, exposing, and minimizing.
- class NSWindowTab A tab associated with a window that is part of a tabbing group.
- class NSWindowTabGroup A group of windows that display together as a single tabbed window.
Window Restoration
- protocol NSWindowRestoration A set of methods that restoration classes must implement to handle the recreation of windows.
- protocol NSUserInterfaceItemIdentification A set of methods used to associate a unique identifier with objects in your user interface.
Screens 屏幕
- clas NSScreen 描述计算机显示器或屏幕属性的一种对象。
Popovers 弹窗
-
class NSPopover 屏幕上显示与现有内容相关的附加内容的方法。
- protocol NSPopoverDelegate 一组 popober 的代理的可选方法,可以用来提供额外或自定的功能。
Alerts 提示
-
class NSAlert 附加到文档窗口的模态对话框或工作表。
- protocol NSAlertDelegate 一组 NSAlert 代理的可选方法,用于响应用户的帮助请求。
Open and Save Panels 打开/保存面板
- class NSOpenPanel 提示用户打开来选择文件的面板
-
class NSSavePanel 提示用户去哪里保存文件的面板。
- protocol NSOpenSavePanelDelegate 一组方法,用来管理打开和保存面板交互。
Print and PDF Panels 打印和PDF面板
- class NSPDFPanel 一个保存或导出PDF 的面板,与macOS用户界面一致。
- NSPrintPanelAccessorizing 一个打印面板对象可以用来从 打印附件控制器中 获取信息 的一组方法。
Color Panels
- class NSColorPanel 在应用程序中选择颜色的标准用户界面。
- protocol NSColorPickingCustom 提供给颜色选择器的一组方法,来 添加颜色选择器、给应用的颜色选择器 自定义用户界面。
- protocol NSColorPickingDefault 提供基本颜色选择行为的一组方法
- class NSColorPicker 一个实现默认的颜色选择协议的抽象父类
Font Panels
- class NSFontPanel The Font panel—a user interface object that displays a list of available fonts, letting the user preview them and change the font used to display text. 字体面板,一个用户界面对象,展示一列可用的字体,让用户预览他们,并修改展示文本。
- struct
- NSFontPanelValidation 一组方法用来告诉 字体面板 去展示部分或全部元素。
- protocol NSFontChanging
7、Sound, Speech, and Haptics 声音、演讲和触觉
/documentation/appkit/sound_speech_and_haptics
在你的界面中 集成 播放音效、触控反馈,合并语音识别。
Sounds 声音
- class NSSound 一个加载和播放音频文件的简单接口。
Speech 语音
- class NSSpeechRecognizer macOS 中语音识别的 Cocoa接口。
- class NSSpeechSynthesizer macOS 中语音合成的 Cocoa接口。
Haptics 触控
- class NSHapticFeedbackManager 在一个 Force Touch 触控板系统上,提供对触控反馈管理属性 访问的对象。
- protocol NSHapticFeedbackPerformer 触控反馈执行者实现的一组方法和常量。
- protocol NSAlignmentFeedbackToken
- NSAlignmentFeedbackFilter 可以过滤对象的动作,当 对准发生时 提供触控反馈 的对象。
8、语言国际化 Localizing Your App
/documentation/xcode/localizing_your_app
通过适应多语言、地区和文化,让你的应用有国际化的受众。
9、Supporting Continuity Camera in Your Mac App 支持连续摄像
/documentation/appkit/supporting_continuity_camera_in_your_mac_app
将用用户的iPhone、iPad或iPod touch拍摄的扫描文件和图片整合到你的Mac应用程序中。
四、用户交互(User Interactions)
管理
1 鼠标、键盘和触控板输入等事件 Mouse, Keyboard, and Trackpad
/documentation/appkit/mouse_keyboard_and_trackpad
Responder Objects
- NSResponder An abstract class that forms the basis of event and command processing in AppKit.
Mouse, Keyboard, and Touch Events
- NSEvent An object that contains information about an input action, such as a mouse click or a key press.
- NSTouch A snapshot of a particular touch at an instant in time.
Trackpad
- NSPressureConfiguration An encapsulation of the behavior and progression of a Force Touch trackpad as it responds to specific events.
- NSHapticFeedbackManager An object that provides access to the haptic feedback management attributes on a system with a Force Touch trackpad.
Constants
- Constants that you use to filter out specific event types from the stream of incoming events.
- - Flags that represent key states in an event object.
- Constants that represent the possible phases during an event phase.
- Constants that specify swipe-tracking options.
init(type: ) Returns the event mask for the specified type.
2 Menus, Cursors, and the Dock 目录、光标和 Dock
/documentation/appkit/menus_cursors_and_the_dock
使用目录和光标,促进和 app 的交互;使用 app Dock tile 来传递更新信息。
Menus
- class NSMenu 管理应用程序菜单的对象。
- class NSMenuItem 应用程序菜单中的命令项。
- protocol NSMenuDelegate NSMenu 对象的代理 用来管理 目录显示 和 处理时间的可选方法。
Menu Validation
- protocol NSMenuItemValidation
Menu Bar Items
- class NSStatusBar 管理 显示在系统范围菜单栏中的 状态项集合 的对象。
- class NSStatusItem 在系统菜单栏中显示的单个元素。
- class NSStatusBarButton 系统范围菜单栏中项的外观和行为。
Cursors 光标
- class NSCursor 光标
- class NSTrackingArea 跟踪区域。视图的一个区域,当指针在该区域上时,该区域会生成鼠标跟踪和指针更新事件。
The Dock
- class NSDockTile 当你的应用程序的小窗口和图标出现在Dock时的 视觉表现。
- protocol NSDockTilePlugIn 插件实现的一组方法,允许在应用程序不运行时定制应用程序的 Dock tile。
3 手势 Gestures
/documentation/appkit/gestures
封装应用的 手势识别的 事件处理逻辑,让代码可以在app内贯穿重用。
Standard Gestures
- NSClickGestureRecognizer A discrete gesture recognizer that tracks a specified number of mouse clicks.
- NSPressGestureRecognizer A discrete gesture recognizer that tracks whether the user holds down a mouse button for a minimum amount of time before releasing it.
- NSPanGestureRecognizer A continuous gesture recognizer for panning gestures.
- NSRotationGestureRecognizer A continuous gesture recognizer that tracks two trackpad touches moving opposite each other in a circular motion.
- NSMagnificationGestureRecognizer A continuous gesture recognizer that tracks a pinch gesture that magnifies content.
Custom Gestures
- NSGestureRecognizer An object that monitors events and calls its action method when a predefined sequence of events occur.
- protocol NSGestureRecognizerDelegate A set of methods for fine-tuning a gesture recognizer’s behavior.
4、 触控条 Touch Bar
/documentation/appkit/touch_bar
在触控条展示交互内容和控件。
Essentials
Integrating a Toolbar and Touch Bar into Your App Build a toolbar in your app’s window, with a corresponding Touch Bar, for quick access to app features.
Creating and Customizing the Touch Bar Use and customize your app’s Touch Bar for macOS.
- NSTouchBar An object that provides dynamic contextual controls in the Touch Bar of supported models of MacBook Pro.
- protocol NSTouchBarDelegate A protocol that allows you to provide the items for a bar dynamically.
- protocol NSTouchBarProvider A protocol that an object adopts to create a bar object in your app.
Touch Bar Items
- NSTouchBarItem A UI control shown in the Touch Bar on supported models of MacBook Pro.
- NSCandidateListTouchBarItem A bar item that, along with its delegate, provides a list of textual suggestions for the current text view.
- NSColorPickerTouchBarItem A bar item that provides a system-defined color picker.
- NSCustomTouchBarItem A bar item that contains a responder of your choice, such as a view, a button, or a scrubber (an instance of the NSScrubber class).
- NSGroupTouchBarItem A bar item that provides a bar to contain other items.
- NSPopoverTouchBarItem A bar item that provides a two-state control that can expand into its second state, showing the contents of a bar that it owns.
- NSSharingServicePickerTouchBarItem A bar item that, along with its delegate, provides a list of objects eligible for sharing.
- NSSliderTouchBarItem A bar item that provides a slider control for choosing a value in a range.
- NSUserInterfaceCompressionOptions An object that specifies how user interface elements resize themselves when space is constrained.
- NSButtonTouchBarItem - NSPickerTouchBarItem - NSStepperTouchBarItem - enum - enum #### Scrubbers
- NSScrubber A customizable item picker control for the Touch Bar.
- NSScrubberDataSource A set of methods that a scrubber data source object implements to provide items to the scrubber from an associated data collection in your app.
- protocol NSScrubberDelegate A set of methods that a scrubber delegate implements to respond to user interactions.
Scrubber Items
- NSScrubberItemView An item at a specific index position in the scrubber.
- NSScrubberArrangedView An abstract base class for the views whose layout is managed by a scrubber.
- NSScrubberImageItemView A concrete view subclass for displaying images in a scrubber items.
- NSScrubberSelectionStyle An abstract class that provides decorative accessory views for selected and highlighted items within a scrubber control.
- NSScrubberSelectionView An abstract base class for specifying the appearance of a highlighted or selected item in a scrubber.
- NSScrubberTextItemView A concrete view subclass for displaying text for an item in a scrubber.
Scrubber Layouts
-
NSScrubberFlowLayout A concrete layout object that arranges items end-to-end in a linear strip.
- protocol NSScrubberFlowLayoutDelegate A protocol that a scrubber delegate can adopt to provide the size of an item.
-
NSScrubberProportionalLayout A concrete layout object that sizes each item to some fraction of the scrubber’s visible size.
-
NSScrubberLayoutAttributes The layout of a scrubber item.
-
NSScrubberLayout An abstract class that describes the layout of items within a scrubber control.
5、拖放 Drag and Drop
/documentation/appkit/drag_and_drop
使用拖放来支持直接操作app。
Drag Sources
Originate content from a drag source by creating items to represent that content.
- protocol NSDraggingSource A set of methods that are implemented by the source object in a dragging session.
- class NSDraggingItem A single dragged item within a dragging session.
- class NSDraggingSession The encapsulation of a drag-and-drop action that supports modification of the drag while in progress.
- class NSDraggingImageComponent 拖动项中的单个对象。
Drop Targets
Receive dragged content in your app’s objects.
- protocol NSDraggingDestination A set of methods that the destination object (or recipient) of a dragged image must implement.
- protocol NSDraggingInfo A set of methods that supply information about a dragging session.
- protocol NSSpringLoadingDestination A set of methods that the destination object (or recipient) of a dragged object can implement to support spring-loading.
6、macOS 辅助功能 Accessibility for macOS
/documentation/appkit/accessibility_for_macos
让你的应用 可以被 任何使用 macOS 的人 来使用。
Essentials
Integrating Accessibility into Your App Make your app more accessible to users with disabilities by adding accessibility features.
Accessibility Design for Mac Catalyst Improve navigation in your app by using keyboard shortcuts and accessibility containers.
- NSAccessibilityProtocol The complete list of properties and methods implemented by accessible elements.
- NSAccessibilityContainsTransientUI A set of methods that support accessibility in a UI that changes dynamically—usually in response to mouse-hover events.
- NSAccessibility
AppKit Elements
- NSAccessibilityElementLoading - protocol NSAccessibilityElementProtocol A role-based protocol that declares the minimum interface required to interact with an accessibility client.
- protocol NSAccessibilityButton A role-based protocol that declares the minimum interface required for an accessibility element to act as a button.
- protocol NSAccessibilityCheckBox A role-based protocol that declares the minimum interface required for an accessibility element to act as a checkbox.
- protocol NSAccessibilityImage A role-based protocol that declares the minimum interface required for an accessibility element to act as an image.
- NSAccessibilityList A role-based protocol that declares the minimum interface required for an accessibility element to act as a list view.
- NSAccessibilityNavigableStaticText A role-based protocol that declares the minimum interface required for an accessibility element to act as navigable static text.
- protocol NSAccessibilityOutline A role-based protocol that declares the minimum interface required for an accessibility element to act as an outline view.
- protocol NSAccessibilityProgressIndicator A role-based protocol that declares the minimum interface required for an accessibility element to act as a progress indicator.
- protocol NSAccessibilityRadioButton A role-based protocol that declares the minimum interface required for an accessibility element to act as a radio button.
- protocol NSAccessibilityRow A role-based protocol that declares the minimum interface required for an accessibility element to act as a row for a table, list, or outline view.
- protocol NSAccessibilitySlider A role-based protocol that declares the minimum interface required for an accessibility element to act as a slider.
- protocol NSAccessibilityStaticText A role-based protocol that declares the minimum interface required for an accessibility element to act as static text.
- protocol NSAccessibilityStepper A role-based protocol that declares the minimum interface required for an accessibility element to act as a stepper.
- protocol NSAccessibilitySwitch A role-based protocol that declares the minimum interface required for an accessibility element to act as a switch.
- protocol NSAccessibilityTable A role-based protocol that declares the minimum interface required for an accessibility element to act as a table view.
- protocol - enum NSAccessibilityAnnotationPosition
Custom Elements
- NSAccessibilityElement The basic infrastructure required to interact with an accessibility client.
- NSAccessibilityGroup A role-based protocol that declares the minimum interface required to act as a container for other user interface elements.
- NSAccessibilityCustomAction
- NSAccessibilityCustomRotor -
- -
- -
- enum -
- enum -
- protocol NSAccessibilityCustomRotorItemSearchDelegate -
- NSAccessibilityLayoutArea A role-based protocol that declares the minimum interface required for an accessibility element to act as a layout area.
- NSAccessibilityLayoutItem A role-based protocol that declares the minimum interface required for an accessibility element to act as a layout item.
Accessibility Types
- -
- typealias NSAccessibilityLoadingToken -
- -
- -
- -
- -
- -
- -
Convenience Functions
var description: String? Returns a standard description for an action.
static func post(element: Any, notification: ) Sends a notification to any observing assistive applications.
static func post(element: Any, notification: , userInfo: [ : Any\]?) Sends a notification and an optional userInfo
dictionary to any observing assistive applications.
static func raiseBadArgumentException(Any!, !, Any!) Raises an error if the parameter is the wrong type or has an illegal value
Deprecated
func description(with: ?) -> String? Returns a standard description for a role and subrole.
static func description(for: Any) -> String? Returns a standard role description for a user interface element.
static func setMayContainProtectedContent(Bool) -> Bool Sets whether the app may have protected content.
static func unignoredChildren(from: [Any\]) -> [Any] Returns a list of unignored accessibility objects, descending the hierarchy if necessary.
static func unignoredChildrenForOnlyChild(from: Any) -> [Any\] Returns a list of unignored accessibility objects, descending the hierarchy if necessary.
static func unignoredDescendant(of: Any) -> Any? Returns an unignored accessibility object, descending the hierarchy if necessary.
static func unignoredAncestor(of: Any) -> Any? Returns an unignored accessibility object, ascending the hierarchy if necessary.
static func screenRect(fromView: NSView, rect: NSRect) -> NSRect Returns the frame in screen coordinates.
static func screenPoint(fromView: NSView, point: NSPoint) -> NSPoint Returns the point in screen coordinates.
Deprecated
protocol NSAccessibility A legacy, informal protocol that is not recommended for active use.
五、Graphics, Drawing, Color, and Printing
1、图片和 PDF Images and PDF
/documentation/appkit/images_and_pdf
创建和管理位图、PDF 和 其他格式的图片。
Images 图片
- {} Providing Images for Different Appearances Supply image resources appropriate for light and dark appearances and for high-contrast environments.
- {} Supporting Continuity Camera in Your Mac App Incorporate scanned documents and pictures taken with a user’s iPhone, iPad, or iPod touch into your Mac app using Continuity Camera.
- NSImage 管理图像数据的高级别接口。
- protocol NSImageDelegate 一组可选方法,可用于响应绘图故障和管理增量载荷。
- NSImageRep 半抽象超类,提供子类,用于从特定类型的源数据 绘制图像。
Bitmap Formats 位图格式
- NSBitmapImageRep 一种根据位图数据呈现图像的对象。
- NSCIImageRep 可以从核心图像对象呈现图像的对象。
- NSPICTImageRep 从版本1、版本2和扩展版本2的PICT格式数据流呈现图像的对象。
Vector Formats 矢量格式
- NSPDFImageRep An object that can render an image from a PDF format data stream.
- NSPDFInfo An object that stores information associated with the creation of a PDF file, such as its URL, tag names, page orientation, and paper size.
- NSEPSImageRep An object that can render an image from encapsulated PostScript (EPS) code.
Custom Formats 自定义格式
- NSCustomImageRep An object that uses a delegate object to render an image from a custom format. 使用代理对象,以自定义格式呈现图像的对象。
2、画图 Drawing
/documentation/appkit/drawing
绘制图形、图片和其他内容。
Drawing Contexts
- class NSGraphicsContext 表示图形上下文的对象。
Shapes and Paths
- class NSBezierPath 可以使用postscript样式命令 创建路径的对象。
- Convenience Functions 可以使用这些方便的函数 绘制矩形和其他原始形状。
Strings
- class NSStringDrawingContext 管理绘制带属性字符串指标的对象。
- struct NSStringDrawingOptions 常量,用于指定绘制字符串的渲染选项。
Gradients
- class NSGradient 一个可以绘制渐变填充颜色的对象
Shadows
- class NSShadow 在绘图操作期间创建投影的属性的封装。
OpenGL
OpenGL 已经过期,使用 Metal 和 MetalKit 来代替
3、颜色 Color
/documentation/appkit/color
使用内置或自定义的格式 展示颜色,给用户选项 来选择和使用颜色。
Colors
- class NSColor An object that stores color data and sometimes opacity (alpha value). 一种存储颜色数据,有时不透明度(alpha值)的 对象。
- class NSColorList 颜色对象的有序列表,由键标识。
- class NSColorSpace 表示自定义颜色空间的对象。
Color Selection
- class NSColorPicker An abstract superclass that implements the default color picking protocol.
- class NSColorWell A control that displays a color value and lets the user change that color value.
- class NSColorPickerTouchBarItem A bar item that provides a system-defined color picker.
Color Sampler
- class NSColorSampler An object that displays the system’s color-sampling interface and returns the selected color to your app.
4、打印 Printing
/documentation/appkit/printing
显示系统打印面板,管理打印过程。
Print Panels
- class NSPrintPanel 向用户询问 有关打印作业的信息的打印面板。
- class NSPageLayout 一种向用户询问 纸张类型和方向等信息的面板。
Print Information
- class NSPrinter 描述打印机功能的对象。
- class NSPrintInfo 存储 用于生成打印输出的信息的对象。
- class NSPrintOperation 控制生成操作 Encapsulated PostScript (EPS) 代码, Portable Document Format (PDF) 代码, 或打印任务 的对象
六、Text
1、 文字展示 Text Display
/documentation/appkit/text_display
展示文字,检查拼写
Text Views
- class NSTextField 用户可以选择或编辑的文本,并在用户按下返回键时 将其操作消息发送给目标。
- protocol NSTextFieldDelegate textField 代理 可用于控制其 field 编辑器操作菜单 的协议。
- class NSTextView 绘制文本并处理用户与该文本交互的视图。
- protocol NSTextViewDelegate 文本视图代理 可用于管理选择、设置文本属性、使用拼写检查器等的一组可选方法。
-
class NSText 用于管理文本的对象的最通用编程接口。
- protocol NSTextDelegate 一个 NSText 对象的代理使用的一组可选方法,用来编辑文本和修改文本格式。
Text Checking
- class NSTextCheckingController
- prototcol NSTextCheckingClient
- protocol NSTextInputTraits
- enum NSTextInputTraitType
Spell Checker
- class NSSpellChecker Cocoa拼写检查服务的接口。
- protocol NSChangeSpelling 响应器对象可以实现的一种协议,用于纠正拼写错误的单词。
- protocol NSIgnoreMisspelledWords 允许 拼写面板中的 Ignore按钮 正常工作 的协议。
2、TextKit
/documentation/appkit/textkit
管理文字储存,在视图中展示自定的文字内容。
Data Management 数据管理
- NSTextStorage The fundamental storage mechanism of TextKit.
- protocol NSTextStorageDelegate The optional methods that delegates of text storage objects implement to handle text-edit processing.
Layout 布局
- NSLayoutManager An object that coordinates the layout and display of text characters.
- protocol NSLayoutManagerDelegate A set of optional methods that delegates of layout manager objects implement.
- NSTextContainer A region where text layout occurs.
- NSATSTypesetter A concrete typesetter object that places glyphs during the text layout process.
- NSTypesetter An abstract class that performs various type layout tasks.
- NSTextLayoutOrientationProvider A set of methods that define the orientation of text for an object.
Formatted Content 格式化内容
- NSTextBlock A block of text laid out in a subregion of the text container.
- NSParagraphStyle The paragraph or ruler attributes for an attributed string.
- NSMutableParagraphStyle An object for changing the values of the subattributes in a paragraph style attribute.
- NSTextTable An object that represents a text table as a whole.
- NSTextTableBlock A text block that appears as a cell in a text table.
- NSTextTab A tab in a paragraph.
- NSTextList A section of text that forms a single list.
- NSTextContentBeta
Attachments 附件
- NSTextAttachment The values for the attachment attributes of attributed strings and related objects.
- NSTextAttachmentCell An object that implements the functionality of the text attachment cell protocol.
- NSTextAttachmentCellProtocol A set of methods that declares the interface for objects that draw text attachment icons and handle mouse events on their icons.
- NSTextAttachmentContainer A set of methods that defines the interface to text attachment objects from a layout manager.
Glyphs 符号
typealias NSGlyph The type used to specify glyphs.
- NSGlyphStorage A set of methods that a glyph storage object must implement to interact properly with NSGlyphGenerator.
- NSGlyphGenerator An object that performs the initial, nominal glyph generation phase in the layout process.
- NSGlyphInfo A glyph attribute in an attributed string.
Glyph Attributes Attributes that are used only inside the glyph generation machinery, but must also be shared between components.
func NSConvertGlyphsToPackedGlyphs(UnsafeMutablePointer, Int, NSMultibyteGlyphPacking, UnsafeMutablePointer) -> Int Prepares a set of glyphs for processing by character-based routines.
Deprecated
Input Management 输入管理
- NSTextInput A set of methods that text views must implement to interact properly with the text input management system.
- NSTextInputClient A set of methods that text views must implement to interact properly with the text input management system.
- NSTextInputContext An object that represents the Cocoa text input system.
- NSTextAlternatives A list of alternative strings for a piece of text.
3、字体 Fonts
/documentation/appkit/fonts
管理显示文字的字体。
Font Data
- class NSFont app 中字体的标识形式。
- class NSFontDescriptor 一个描述字体属性的字典。
- struct NSFontTraitMask 分离字体特定特征的常数。
- typealias NSFontFamilyClass 对字体特定风格特征进行分类的常数。
- struct 字体样式方面的符号描述。
- class NSFontAssetRequest
- typealias NSFontSymbolicTraits 字体样式方面的符号描述。
Management
- class NSFontManager 字体转换系统的活动中心。
- class NSFontCollection 描述单个对象 的字体描述集合。
- class NSMutableFontCollection 字体描述的可变集合。
- struct NSFontCollectionOptions 支持字体集合管理的常量。
三、其它
过期 Deprecated
Avoid using deprecated classes and protocols in your apps.
Deprecated Symbols Review symbols that are no longer supported, and find the replacements to use instead.
伊织 2020-10-02