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