macOS/iOS API解説

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

目次

setFlipped:

y軸の極性が逆にされます
-(void)setFlipped:(BOOL)flag:

解説

y軸の極性が逆にされます。

返り値

( void )

なし

引数

( BOOL )flag

逆にするYES/NO

フレームワーク

ApplicationKit

クラス

NSImage

Instance Methods

使用可能

10.0

参照

- recache

例文

#import "SetImage.h"

@implementation SetImage

- (IBAction)set:(id)sender
{
    //開けるファイル拡張子の配列
    NSArray      *imgTypes    = [ NSArray arrayWithObject : @"tiff" ];
    //OpenPanelを作る
    NSOpenPanel  *opImage       = [ NSOpenPanel openPanel ];
    //Imageを作る
    NSImage      *img;
     NSImage      *img2;
    //OpenPanelの結果のボタン番号
    int		  opRet;
     
        //OpenPanelでファイル選択   
    opRet = [ opImage runModalForDirectory : NSHomeDirectory() //どこのディレクトリを出すか
                                     file : @"Pictures" //どのどのファイルを選択しておくか
                                    types : imgTypes ];//選べるファイルタイプ

    if ( opRet == NSOKButton ) {  // OPENPanelのボタンがOKなら
        //NSImageを作ってファイルから読み込む
        img = [ [ NSImage alloc ] 
                          initWithContentsOfFile: [ opImage filename ] ];
        //NSImageをバンドルファイルからつくる
        img2 = [NSImage imageNamed: @"NSApplicationIcon" ];
        
        //imgを描画対象にする
        [img lockFocus];
        //描画対象にimg2を合成する
           [img2 setFlipped:YES];
        [img2 dissolveToPoint:NSMakePoint(10,100) 
                fromRect:NSMakeRect(0.0,0.0,80.0,80.0)
                fraction:0.5];
        //合成後のimgをImageViewに表示する
        [image setImage:img];
        //imgを描画から外す
        [img unlockFocus];
    }
}

@end