macOS/iOS API解説

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

目次

NSDivideRect

指定した矩形の範囲を指定した割合で縦または横に分割した2つの矩形を返します
void  NSDivideRect ( 
       NSRect   inRect , 
       NSRect *   slice , 
       NSRect *   remainder , 
       float   amount , 
       NSRectEdge   edge );

解説

指定した矩形(inRect)の範囲を指定した割合(amount)で縦または横(edge)に分割した2つの矩形(slice,remainder)を返します。

返り値

引数

( NSRect )inRect
( NSRect * )slice
( NSRect * )remainder
( float )amount
( NSRectEdge )edge

クラス

NSDivideRect

Function

使用可能

10.0

参照

NSInsetRect
NSIntegralRect
NSOffsetRect

例文

#import "MyObject.h"

@implementation MyObject

- (IBAction)myAction:(id)sender
{
NSRect rect = NSMakeRect(100,100,100,100);
NSRect aFrame ;
NSRect bFrame ;

NSDivideRect (rect, &aFrame, &bFrame, 30, NSMinXEdge);


[image lockFocus];//imageにフォーカス

[[NSColor blueColor] set];//青色で塗る
NSRectFill(aFrame);//a塗る
[[NSColor yellowColor] set];//黄色で塗る
NSRectFill(bFrame);//b塗る

[image unlockFocus];//フォーカス外す
}

@end