macOS/iOS API解説

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

目次

knobRectFlipped:

ノブの矩形を返します
-(NSRect)knobRectFlipped:(BOOL)flipped:

解説

ノブの矩形を返します。サブクラスでオーバーライドして、独自のノブを描画することができます。

返り値

( NSRect )

矩形

引数

( BOOL )flipped

YES/NO

フレームワーク

ApplicationKit

クラス

NSSliderCell

Instance Methods

使用可能

10.0

参照

例文

#import "MySliderCell.h"
//スライダーセルのサブクラス
@implementation MySliderCell


-(void)drawKnob
{
NSColor *theColor = [NSColor redColor];//カラー作成
//NSImageをバンドルファイルからつくる
NSImage *img2 = [NSImage imageNamed: @"NSApplicationIcon" ];
NSRect rect = [self knobRectFlipped:YES];

//描画対象にimg2を合成する
        [img2 drawAtPoint:NSMakePoint(0,0) 
            fromRect:NSMakeRect(0.0,0.0,128.0,128.0)
            operation:NSCompositeSourceOver
            fraction:0.8
            ];
            
[theColor drawSwatchInRect:rect];
NSLog([NSString stringWithFormat:@"%.1f,%.1f",rect.origin.x,rect.origin.y]);
//[super drawKnob];
}
@end