NSView で繰り返し背景画像を描画しようとしていますが、今までこれを持っています:
// INIT
- (id)initWithFrame:(NSRect)frame {
if (self = [super initWithFrame:frame]) {
self.backgroundImage = [NSImage imageNamed:@"progressBackground.pdf"];
}
return self;
}
// DRAW
- (void)drawRect:(NSRect)dirtyRect {
// Draw the background
[backgroundImage drawInRect:[self bounds]
fromRect:NSMakeRect(0.0f, 0.0f, backgroundImage.size.width, backgroundImage.size.height)
operation:NSCompositeSourceAtop
fraction:1.0f];
NSLog(@"%dx%d", backgroundImage.size.width, backgroundImage.size.height);
}
ただし、ビューは画像を引き伸ばしてそれ自体を埋めます。代わりに画像を繰り返したい。
(黒いストロークはすでに修正されています)
また、コンソールには画像のサイズが等しいと表示されるため、奇妙なことが起こります-2109897792x0
が、画像は実際には32x32
です! なんてこと?!
誰か助けてくれませんか?ありがとう。