macOS/iOS API解説

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

目次

getLineDash:count:phase:

INDEX>AppKit>NSBezier

ラインのパターンを返します

Objective-C

- (void)getLineDash:(CGFloat *)pattern
              count:(NSInteger *)count
              phase:(CGFloat *)phase

Swift

func getLineDash(_ pattern: UnsafeMutablePointer<CGFloat>,
           count count: UnsafeMutablePointer<Int>,
           phase phase: UnsafeMutablePointer<CGFloat>)

解説

ラインのパターンを返します
patternにfloatの配列
countはパターンの要素数
phaseは開始するポイント。
にそれぞれの値を入れる。

返り値

Objective-C

Swift


    
( void )

なし

引数

Objective-C

Swift


    
( float * )pattern

塗り、空きの配列

( int * )count

塗り、空きの配列の要素数

( float * )phase

書き始め(ポイント)

フレームワーク

ApplicationKit

クラス

NSBezierPath

使用可能

10.0

参照


setLineDash:count:phase: - Cocoa API解説(iOS/OS X)

関連記事(外部サイト)

例文

Objective-C

#import "MyView.h"

@implementation MyView

//NSViewのサブクラス MyViewのDrawRectに上書き
-(void)drawRect:(NSRect)rect
{
float array[4];
float retArray[4];
float retPhase;
int retCount;
NSBezierPath *thePath = [NSBezierPath bezierPath];

[NSBezierPath setDefaultLineJoinStyle:NSBevelLineJoinStyle];

[thePath moveToPoint:NSMakePoint(20,20)];
[thePath lineToPoint:NSMakePoint(120,120)];
[thePath lineToPoint:NSMakePoint(40,20)];


[thePath appendBezierPathWithRect:NSMakeRect(50,50,100,100)];
[thePath setFlatness:0.5];
[thePath setLineWidth:5];
[[NSColor redColor] set];

array[0] = 8.0; //塗る
array[1] = 3.0; //塗らない
array[2] = 20.0; //塗る
array[3] = 3.0; //塗らない
[thePath setLineDash: array count: 4 phase: 0.0];
[thePath getLineDash:retArray count:&retCount phase:&retPhase];
[thePath stroke];
NSLog([NSString stringWithFormat:@"array'%.1f,%.1f,%.1f,%.1f' count %d phase %.1f",retArray[0],retArray[1],retArray[2],retArray[3],retCount,retPhase]);

}

@end

Swift


    

更新時バージョン

10.10