gpt4 book ai didi

objective-c - 制作一个复选框来打开和关闭 Dock 图标

转载 作者:太空狗 更新时间:2023-10-30 03:23:11 25 4
gpt4 key购买 nike

如果复选框被选中,我如何让它隐藏停靠栏图标?我已经制作了一个复选框来切换菜单栏项目,但是您将如何使用停靠栏图标进行操作?寻找一些代码来做到这一点。谢谢!

最佳答案

Swift 的更新,使用上面介绍的两种方式(它们给出相同的结果):

public class func toggleDockIcon_Way1(showIcon state: Bool) -> Bool {
// Get transform state.
var transformState: ProcessApplicationTransformState
if state {
transformState = ProcessApplicationTransformState(kProcessTransformToForegroundApplication)
}
else {
transformState = ProcessApplicationTransformState(kProcessTransformToUIElementApplication)
}

// Show / hide dock icon.
var psn = ProcessSerialNumber(highLongOfPSN: 0, lowLongOfPSN: UInt32(kCurrentProcess))
let transformStatus: OSStatus = TransformProcessType(&psn, transformState)
return transformStatus == 0
}

public class func toggleDockIcon_Way2(showIcon state: Bool) -> Bool {
var result: Bool
if state {
result = NSApp.setActivationPolicy(NSApplicationActivationPolicy.Regular)
}
else {
result = NSApp.setActivationPolicy(NSApplicationActivationPolicy.Accessory)
}
return result
}

关于objective-c - 制作一个复选框来打开和关闭 Dock 图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1082374/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com