setGlyphGenerator:
グリフジェネレーターをセットします
-(void)setGlyphGenerator:(NSGlyphGenerator *)glyphGenerator:
解説
グリフジェネレーターをセットします。
返り値
( void )
なし
引数
( NSGlyphGenerator * )glyphGenerator
フレームワーク
ApplicationKit
クラス
NSLayoutManager
Instance Methods
使用可能
10.4
参照
-glyphGenerator
例文
#import "MyObject.h" @implementation MyObject - (void)awakeFromNib { //1.テキストストレージを作る textStorage = [[NSTextStorage alloc] init]; //2.レイアウトマネージャーを作る layoutManager = [[MyLayoutManager alloc] init]; //3.テキストストレージにレイアウトマネージャーを追加 3 //今までのを削除 id obj; NSEnumerator *aKeyEnumerator = [ [textStorage layoutManagers] objectEnumerator ]; while (obj = [aKeyEnumerator nextObject]) { [textStorage removeLayoutManager: obj]; } [textStorage addLayoutManager:layoutManager]; //4.テキストコンテナ作成 textContainerLeft = [[MyTextContainer alloc] initWithContainerSize:NSMakeSize(100,100)]; //5.テキストビューにテキストコンテナをセット [textViewLeft replaceTextContainer: textContainerLeft]; //6.レイアウトマネージャーにテキストコンテナをセット [layoutManager addTextContainer:textContainerLeft]; [layoutManager setDelegate:self]; [layoutManager setGlyphGenerator: [NSGlyphGenerator sharedGlyphGenerator] ]; } -(void)dealloc { [textContainerLeft release]; [textStorage release]; [layoutManager release]; [super dealloc]; } - (IBAction)myAction:(id)sender { } //デリゲートメソッド //完了した -(void)layoutManager:(NSLayoutManager *)aLayoutManager didCompleteLayoutForTextContainer:(NSTextContainer *)aTextContainer atEnd:(BOOL)flag { NSRange theRange = NSMakeRange(0, [aLayoutManager numberOfGlyphs]); [aLayoutManager drawGlyphsForGlyphRange: theRange atPoint: NSMakePoint(10,10)]; NSLog([NSString stringWithFormat:@"%d",theRange.length]); } //無効になった -(void)layoutManagerDidInvalidateLayout:(NSLayoutManager *)aLayoutManager { //NSLog(@"layoutManagerDidInvalidateLayout"); } @end