macOS/iOS API解説

iOS , Mac アプリケーション開発のために使われる主要フレームワークの日本語情報です。2010年代に書かれた内容です。今後更新はありません。

目次

allowsVibrancy

INDEX>AppKit>NSAppearance

現在のアピアランスがvibrancyを適用できるかどうか

Objective-C

@property(readonly) BOOL allowsVibrancy

Swift

var allowsVibrancy: Bool { get }

解説

現在のアピアランスがvibrancyを適用できるかどうか

フレームワーク

ApplicationKit

クラス

NSAppearance

使用可能

10.9-

更新時のバージョン

OS X 10.11

参照

関連記事

例文

    //NSAppearance initWithAppearanceNamed:bundle:
    //http://cocoaapi.hatenablog.com/entry/Appkit/NSAppearance/initWithAppearanceNamed_bundle_
    //NSAppearance name
    //http://cocoaapi.hatenablog.com/entry/Appkit/NSAppearance/name
    //NSAppearance appearanceNamed:
    //
    func buttonAction001(sender: AnyObject)
    {
        let newAp : NSAppearance = NSAppearance(named: NSAppearanceNameAqua)!
        NSAppearance.setCurrentAppearance(newAp)
        NSLog("name = %@",newAp.name)
    }
    @IBAction func function001( sender: AnyObject) {
        //アピアランスの変更
        let ap : NSAppearance = NSAppearance(named: NSAppearanceNameVibrantDark)!
        NSLog("name = %@",ap.name)
        
        NSLog("name = %@",ap.name)
        //->name = NSAppearanceNameVibrantDark
        let aWindow : NSWindow
        = NSWindow(contentRect: NSMakeRect(0.0, 0.0, 300.0, 200.0),
            styleMask: NSTitledWindowMask
                | NSClosableWindowMask
                | NSMiniaturizableWindowMask
                | NSResizableWindowMask,
            backing: .Buffered,
            `defer`: false,
            screen: NSScreen.mainScreen())
        windowArray.addObject(aWindow) //ウインドウを保持するための配列に追加。アプリ終了時に配列は破棄
        aWindow.appearance = ap
        aWindow.center()//ウインドウをスクリーンの中心に
        aWindow.title = "ウインドウタイトル"//タイトル設定
        //
        let theButton : NSButton = NSButton(frame: NSMakeRect(50.0, 50.0, 100.0, 30.0))
        theButton.title = "Change"
        theButton.bezelStyle = NSBezelStyle.RoundedBezelStyle
        theButton.action = Selector("buttonAction001:")
        theButton.target = self
        theButton.setButtonType(.MomentaryLightButton)
        //.SwitchButton
        //.PushOnPushOffButton
        aWindow.contentView!.addSubview(theButton)
        
        aWindow.orderFront(self)//前面に
        aWindow.makeKeyAndOrderFront(self)//表示
        
        NSLog("current name = %@",NSAppearance.currentAppearance().name)
        
        if (ap.allowsVibrancy){
            NSLog("YES")
        }else{
            NSLog("NO")
        }
        
    }