本文介绍了如何更改停靠图标使用setContentView显示一个大字符在mac os x的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将应用程式的Dock图示变更为一个大字元,例如使用快速或目标C的「A」或「B」。

I want to change the dock icon of an app into one big character like an "A" or "B" for example using swift or objective C

推荐答案

import Cocoa

@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {

    @IBOutlet weak var window: NSWindow!

    @IBOutlet weak var dockView: NSView!
    @IBOutlet weak var dockText: NSTextField!
    let appDockTile =  NSApplication.sharedApplication().dockTile

    func prepareDock(){
        appDockTile.contentView = dockView
        appDockTile.display()
    }
    func changeText(){
        dockText.stringValue = "B"
         appDockTile.display()
    }
    func applicationDidFinishLaunching(aNotification: NSNotification) {
        // Insert code here to initialize your application
        prepareDock()

    }

    func applicationWillTerminate(aNotification: NSNotification) {
        // Insert code here to tear down your application
    }

    @IBAction func btnChangeText(sender: AnyObject) {
        changeText()
    }

}

这篇关于如何更改停靠图标使用setContentView显示一个大字符在mac os x的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 17:29