窗口的阴影大致有以下几种表现:
NSWindow默认阴影效果但是有时候这个行为不让PM满意,遗憾的是AppKit并没有对外暴露接口以供我们更改窗口的shadow效果,但我找到了如下方法以供参考。
改变NSWindow的阴影效果相关的方法
OFFSET:
-(NSSize)_shadowOffset; //!< Titled (0, 8), Borderless (0, 4)
-(NSSize)_shadowOffsetForActiveAppearance:(BOOL)arg1;//!< 顾名思义
- (NSSize)_shadowOffsetForOptions:(unsigned long long)arg1;//!< 参数未研究
RIM:
- (NSDictionary*)_shadowRimInfo;//<! 比如 @{@"kCUIMeasureWindowFrameRimDensity" : @(0)}
OVERRALL:
- (NSDictionary*)shadowParameters;
/* 比如 Titled
"com.apple.WindowShadowDensityActive" = "0.5";
"com.apple.WindowShadowDensityInactive" = "0.3";
"com.apple.WindowShadowRadiusActive" = 20;
"com.apple.WindowShadowRadiusInactive" = 15;
"com.apple.WindowShadowRimDensityActive" = 0;
"com.apple.WindowShadowRimDensityInactive" = 0;
"com.apple.WindowShadowRimStyleHardActive" = 0;
"com.apple.WindowShadowRimStyleHardInactive" = 0;
"com.apple.WindowShadowVerticalOffsetActive" = 24;
"com.apple.WindowShadowVerticalOffsetInactive" = 8;
*/
REFRESH: 非必须
self.hasShadow = NO; self.hasShadow = YES; //!< or [self invalidateShadow]
效果:
点击上面图片内容查看原图
网友评论