文章目录
一、简介
系统偏好设置面板 并不是一个独立的App ,而是由一个个 PreferencePanes 文件构成。
如网络设置是 /System/Library/PreferencePanes/Network.prefPane
, 双击这个文件就可以加载 网络设置面板。
右键选中这个文件,可以查看包内容;跟一个 .app 文件一样,它是一个 bundle。真正的可执行文件依然是 Contents/MacOS
里的这个 mach-o 文件:
/System/Library/PreferencePanes/Network.prefPane/Contents/MacOS/Network
。
二、PreferencePanes 存储地址
和很多文件结构一样,PreferencePanes 也分别保存在 系统文件夹、管理员文件夹、用户文件夹:
/System/Library/PreferencePanes
/Library/PreferencePanes
, 如Flash Player.prefPane
~/Library/PreferencePanes
三、常见系统偏好设置面板
其中 /System/Library/PreferencePanes
中保存了偏好设置中最常见的偏好设置面板。
- Accounts.prefPane // 用户与群组
- Network.prefPane // 网络
- AppStore.prefPane
- Notifications.prefPane
- Appearance.prefPane // 通用
- ParentalControls.prefPane
- Bluetooth.prefPane
- PrintAndFax.prefPane // 指向 PrintAndScan.prefPane 的软连接。
- PrintAndScan.prefPane // 打印机与扫描仪
- DateAndTime.prefPane
- DesktopScreenEffectsPref.prefPane
- Profiles.prefPane
- DigiHubDiscs.prefPane // CD与DVD设置(不可用)
- Security.prefPane
- Displays.prefPane
- SharingPref.prefPane
- Dock.prefPane
- Sound.prefPane
- EnergySaver.prefPane // 节能
- Speech.prefPane // Siri
- Expose.prefPane // 调度中心
- Spotlight.prefPane
- Extensions.prefPane
- StartupDisk.prefPane // 启动磁盘
- FibreChannel.prefPane // 管线通道(不可用)
- TimeMachine.prefPane
- Ink.prefPane (不可用)
- TouchID.prefPane // 触控ID(不可用)
- InternetAccounts.prefPane
- Trackpad.prefPane // 触控板
- Keyboard.prefPane
- UniversalAccessPref.prefPane // 辅助功能
- Localization.prefPane // 语言与地区
- Wallet.prefPane // 钱包与 Apple Pay(不在偏好设置面板)
- Mouse.prefPane
- iCloudPref.prefPane
四、Cocoa 编程相关
1、创建 project
偏好设置类型应用,创建时project 类型应该选择 Preference Pane,而非 Cocoa App.
创建project 成功后,会自动生成 .h , .m , .tiff , .xib 文件。
想要自定义在面板上的图标,把原来的tiff 替换掉即可。
2、PreferencePanes.framework
系统偏好设置在 PreferencePanes.framework 这个框架中,使用的时候如下引用:
#import <PreferencePanes/PreferencePanes.h>
这个框架只有两个文件:PreferencePanes.h
和 NSPreferencePane.h
。
其中PreferencePanes.h 中只有一句话 #import <PreferencePanes/NSPreferencePane.h>
, 所以可以理解为这个框架只有 NSPreferencePane.h
。
NSPreferencePane 继承自 NSObject.
3、运行、安装你的pane
在xcode 上运行project,即可生成 .prefPane
文件在product 下面。
双击这个文件,会帮助你安装到 ~/Library/PreferencePanes
下。可能会重启系统偏好设置面板。