我有一個自定義框,我已經是NSBox
的子類。我重寫drawRect:
方法,並在其中繪製一個梯度這樣(假設我已經有一個start
& end
顏色):NSScrollView搞砸NSGradient(腐敗)
-(void)drawRect:(NSRect)dirtyRect {
NSGradient *gradient = [[NSGradient alloc] initWithStartingColor:start endingColor:end];
[gradient drawInRect:dirtyRect angle:270];
[gradient release];
}
查閱此框被添加作爲用於NSCollectionView
原型圖的子視圖。在視圖的原始狀態,它看起來像這樣:
和滾動視圖的視線並重新之後,它看起來像這樣:
爲什麼我的梯度像這樣被損壞了,我該如何解決它?謝謝!
您獲獎。只需要調用'[gradient gradientInRect:[self bounds] angle:270];'並且解決了問題。謝謝!我會在可用時接受它。 –
那麼我想,我會將它更新爲'[self-bounds]'而不是'[self frame]'。 – icktoofay
好的。我會問你同樣的問題,我問Bavarious,是否有一個更好的地方來繪製這個,而不是'drawRect:'? –