macOS - 偏好设置面板 PreferencePanes

版权声明:本文为博主原创文章,转载请附上本文链接地址。from : https://blog.csdn.net/lovechris00 https://blog.csdn.net/lovechris00/article/details/89100754


一、简介

系统偏好设置面板 并不是一个独立的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 中保存了偏好设置中最常见的偏好设置面板。

  1. Accounts.prefPane // 用户与群组
  2. Network.prefPane // 网络
  3. AppStore.prefPane
  4. Notifications.prefPane
  5. Appearance.prefPane // 通用
  6. ParentalControls.prefPane
  7. Bluetooth.prefPane
  8. PrintAndFax.prefPane // 指向 PrintAndScan.prefPane 的软连接。
  9. PrintAndScan.prefPane // 打印机与扫描仪
  10. DateAndTime.prefPane
  11. DesktopScreenEffectsPref.prefPane
  12. Profiles.prefPane
  13. DigiHubDiscs.prefPane // CD与DVD设置(不可用)
  14. Security.prefPane
  15. Displays.prefPane
  16. SharingPref.prefPane
  17. Dock.prefPane
  18. Sound.prefPane
  19. EnergySaver.prefPane // 节能
  20. Speech.prefPane // Siri
  21. Expose.prefPane // 调度中心
  22. Spotlight.prefPane
  23. Extensions.prefPane
  24. StartupDisk.prefPane // 启动磁盘
  25. FibreChannel.prefPane // 管线通道(不可用)
  26. TimeMachine.prefPane
  27. Ink.prefPane (不可用)
  28. TouchID.prefPane // 触控ID(不可用)
  29. InternetAccounts.prefPane
  30. Trackpad.prefPane // 触控板
  31. Keyboard.prefPane
  32. UniversalAccessPref.prefPane // 辅助功能
  33. Localization.prefPane // 语言与地区
  34. Wallet.prefPane // 钱包与 Apple Pay(不在偏好设置面板)
  35. Mouse.prefPane
  36. 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.hNSPreferencePane.h

其中PreferencePanes.h 中只有一句话 #import <PreferencePanes/NSPreferencePane.h> , 所以可以理解为这个框架只有 NSPreferencePane.h

NSPreferencePane 继承自 NSObject.


3、运行、安装你的pane

在xcode 上运行project,即可生成 .prefPane 文件在product 下面。
双击这个文件,会帮助你安装到 ~/Library/PreferencePanes 下。可能会重启系统偏好设置面板。

猜你喜欢

转载自blog.csdn.net/lovechris00/article/details/89100754