macOS/iOS API解説

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

目次

contentSize

INDEX>AppKit>NSDrawer

引き出しの内容ビューのサイズを返します

Objective-C

@property NSSize contentSize

Swift

var contentSize: NSSize

解説

引き出しの内容ビューのサイズを返します。

設定値

サイズ
Objective-C

@property NSSize contentSize

Swift

var contentSize: NSSize

フレームワーク

ApplicationKit

クラス

NSDrawer

使用可能

10.0

参照

cocoaapi.hatenablog.com

cocoaapi.hatenablog.com

更新時のバージョン

OS X 10.10.2

関連記事(外部サイト)

例文

#import "MyObject.h"

@implementation MyObject

- (IBAction)myAction1:(id)sender
{
[drawer open];
[drawer setContentSize:NSMakeSize(50,50)];
NSLog([NSString stringWithFormat:@"width=%.1f,height=%.1f",[drawer contentSize].width,[drawer contentSize].height]);
}

- (IBAction)myAction2:(id)sender
{
[drawer close];
}

@end

Swift

//NSDrawer contentSize
    var theDrawer006 : NSDrawer = NSDrawer(contentSize: NSMakeSize(100.0, 100.0),
        preferredEdge: 1 )
    //preferredEdge 0=左、1=下、2=右、3=上
    func buttonAction006(sender: AnyObject){
        
        var theWindow : NSWindow = (sender as NSButton).window!

        //drawerを表示/非表示
        theDrawer006.toggle(theWindow)
        NSLog("size = (%.2f,%.2f)", Float(theDrawer006.contentSize.width),Float(theDrawer006.contentSize.height))
        
        //drawerを表示/非表示
        theDrawer006.toggle(theWindow)
    
    }
    @IBAction func function006(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 = "Toggle"
        theButton.bezelStyle = NSBezelStyle.RoundedBezelStyle
        theButton.action = Selector("buttonAction006:")
        theButton.target = self
        
        aWindow.contentView.addSubview(theButton)
        
        let delegateObj : DrawerDelegate = DrawerDelegate()
        delegateObjects.addObject(delegateObj)
        theDrawer001.delegate = delegateObj
        NSLog("delegate = %@",delegateObj)
        
        //テキストフィールドを作成、引き出しに付ける
        var textField : NSTextField = NSTextField(frame: NSMakeRect(10.0, 10.0, 50.0, 30.0))
        theDrawer001.contentView?.addSubview(textField)
        
        //引き出しのウインドウを設定
        theDrawer001.parentWindow = aWindow
        
        //ウインドウの表示
        aWindow.center()//ウインドウをスクリーンの中心に
        aWindow.title = "ウインドウタイトル"//タイトル設定
        aWindow.orderFront(self)//前面に
        aWindow.makeKeyAndOrderFront(self)//表示
    }