我的Mac OS X应用程序中需要两个类似于Pages应用程序的东西。请查看随附的屏幕截图。
答案 0 :(得分:0)
using System.Runtime.Serialization;
namespace Etc.
{
[DataContract] public class Email()
{}
}
选项来实现的。只需查看IB中的CALayer
(或者您也可以通过编程方式执行此操作 - read this)View Effects Inspector
样式为"默认样式" (第二行)。 答案 1 :(得分:0)
获取顶部阴影的快捷方法是覆盖封闭的剪辑视图。然而,这并不理想,因为它在控件后面绘制阴影(实际上是渐变)。我觉得它很好。
#import <Cocoa/Cocoa.h>
// DFInvertedClipView.h
IB_DESIGNABLE
@interface DFInvertedClipView : NSClipView
@property IBInspectable BOOL shouldDrawTopShadow;
@end
// DFInvertedClipView.m
#import "DFInvertedClipView.h"
@interface DFInvertedClipView ()
@property CGFloat startAlpha;
@end
@implementation DFInvertedClipView
- (BOOL) isFlipped {
return true;
}
-(void) drawRect:(NSRect)dirtyRect
{
[super drawRect:dirtyRect];
if (_shouldDrawTopShadow) {
NSGradient * gradient = [[NSGradient alloc] initWithStartingColor:[NSColor colorWithCalibratedWhite:0.6 alpha:self.startAlpha]
endingColor:[NSColor colorWithCalibratedWhite:0.6 alpha:0.0]];
NSRect b = [self bounds];
NSRect topFade = NSMakeRect(NSMinX(b), NSMinY(b), NSWidth(b), 5.0);
[gradient drawInRect:topFade angle:90];
NSBezierPath *topLine = [NSBezierPath bezierPath];
[topLine moveToPoint:NSMakePoint(NSMinX(self.bounds), NSMinY(self.bounds))];
[topLine lineToPoint:NSMakePoint(NSMaxX(self.bounds), NSMinY(self.bounds))];
CGFloat lineWidth = [[NSScreen mainScreen] backingScaleFactor];
[topLine setLineWidth:lineWidth];
[[NSColor colorWithCalibratedWhite:0.5 alpha:self.startAlpha] setStroke];
[topLine stroke];
}
}
-(void) scrollToPoint:(NSPoint)newOrigin
{
[super scrollToPoint:newOrigin];
// Grade the shadow darkness based on the displacement from a flush fit
CGFloat displacementForFullShadow = 40.0; // pixels
if (newOrigin.y > 0) {
CGFloat alpha = 1.0/displacementForFullShadow * newOrigin.y; // e.g. linear grade function y = m*x + c (m = 1/displacementForFullShadow, c = 0.0)
if (alpha > 1.0) {
alpha = 1.0;
}
self.startAlpha = alpha;
} else {
self.startAlpha = 0.0;
}
}