macOS/iOS API解説

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

目次

aspectRatio

INDEX>AppKit> NSWindow

ウインドウのアスペクト比

Objective-C

@property NSSize aspectRatio

Swift

var aspectRatio: NSSize

解説

ウインドウのアスペクト比

設定値

Objective-C

@property NSSize aspectRatio

Swift

var aspectRatio: NSSize

クラス

NSWindow

使用可能

10.0-

参照

関連記事(外部サイト)

例文

Objective-C

Swift

    //NSWindow aspectRatio
    func buttonAction058(sender: AnyObject){
        
        var theWindow : NSWindow = (sender as NSButton).window!
        theWindow.aspectRatio = NSMakeSize(1.78,1.0)//(16:9)
    }
    @IBAction func function058(sender: AnyObject) {
        var aWindow : NSWindow = NSWindow(contentRect: NSMakeRect(0.0, 0.0, 300, 200),
            styleMask:  NSTitledWindowMask |
                NSClosableWindowMask |
                NSMiniaturizableWindowMask |
            NSResizableWindowMask,
            backing:    .Buffered,
            defer:      false)
        windowArray.addObject(aWindow) //ウインドウを保持するための配列に追加。アプリ終了時に配列は破棄
        
        //ボタンを作成
        var theButton : NSButton = NSButton(frame: NSMakeRect(100.0, 2.0, 100.0, 30.0))
        theButton.title = "set"
        theButton.bezelStyle = NSBezelStyle.RoundedBezelStyle
        theButton.action = Selector("buttonAction058:")
        theButton.target = self
        aWindow.contentView.addSubview(theButton)
        
        //ウインドウの表示
        aWindow.center()//ウインドウをスクリーンの中心に
        aWindow.title = "ウインドウタイトル"//タイトル設定
        aWindow.orderFront(self)//前面に
        aWindow.makeKeyAndOrderFront(self)//表示
    }

更新時のバージョン

OS X 10.10