macos - 如何在 Delphi macOS 应用程序中检测暗模式
问题描述
如何在 Delphi Firemonkey macOS(例如 Big Sur)应用程序中检测暗模式?
Lazarus 有代码,但 Firemonkey 没有。
解决方案
您可以使用 FireMonkey 平台服务来获取该信息:
uses
FMX.Platform;
function GetSystemTheme: TSystemThemeKind;
var
LService: IFMXSystemAppearanceService;
begin
Result := TSystemThemeKind.Unspecified;
if TPlatformServices.Current.SupportsPlatformService(IFMXSystemAppearanceService, LService) then
Result := LService.GetSystemThemeKind;
end;
在哪里TSystemThemeKind
声明为
TSystemThemeKind = (Unspecified, Light, Dark);
IFMXSystemAppearanceService
目前支持 Android、iOS 和 macOS。
推荐阅读
- javascript - 将 Axios 响应作为 prop 发送到组件
- python-2.7 - 我正在尝试为我的 GUI 应用程序设置固定框架。窗口不应改变其大小
- spring-mvc - 在两个不同的 @RestController 类中有两个完全相同的 @ExceptionHandler 是不好的做法吗?
- x86-16 - 实模式下的有效寻址 - 访问数组
- kubernetes - 在我的情况下,为什么 pod 状态会以 crashloopbackoff 的形式出现?
- hadoop - 纱线公平调度程序没有均匀分配资源
- redis - 有没有办法在将记录添加到redis中的键时发布消息?
- django - 当通过渲染传递变量时,我尝试尝试许多解决方案来解决 django 中的 HTTP 状态代码必须是整数
- json - React:为 setState 传递带有事件的 Prop
- html - 应用 Web 字体样式时,文本徽标会不规律地改变形状