5
的頂部和底部我在尋找一種方式來畫上一個表視圖淡入淡出效果(和大綱視圖,但我認爲這將是相同的),當滾動內容。下面是從Fantastical應用的例子:淡出效果在NSTableView的/ NSOutlineView
另外一個類似的淡入的上QuickLook的窗口here的視頻。
爲了這個,我試着子類一的tableview的滾動視圖使用此代碼:
#define kFadeEffectHeight 15
@implementation FadingScrollView
- (void)drawRect: (NSRect)dirtyRect
{
[super drawRect: dirtyRect];
NSGradient* g = [[NSGradient alloc] initWithStartingColor: [NSColor blackColor] endingColor: [NSColor clearColor]];
NSRect topRect = self.bounds;
topRect.origin.y = self.bounds.size.height - kFadeEffectHeight;
topRect.size.height = kFadeEffectHeight;
NSRect botRect = self.bounds;
botRect.size.height = kFadeEffectHeight;
[NSGraphicsContext saveGraphicsState];
[[NSGraphicsContext currentContext] setCompositingOperation: NSCompositeDestinationAtop];
// Tried every compositing operation and none worked. Please specify wich one I should use if you do it this way
[g drawInRect: topRect angle: 90];
[g drawInRect: botRect angle: 270];
[NSGraphicsContext restoreGraphicsState];
}
...但是這並沒有什麼褪色,可能是因爲這是實際的表視圖之前調用畫了。我對如何做到這一點:(
順便說一句,無論是tableview中,我想有這種效果的outlineview不知道是基於視圖,應用程序是隻10.7。
可以爲您提供的效果,或者你鼓舞人心上的應用程序的iTunes的鏈接視頻? – viggio24 2011-12-22 12:48:07
@ viggio24在應用商店中添加了Fantastical的鏈接,並在另一個示例中添加了視頻 – Alex 2011-12-22 13:33:52