gpt4 book ai didi

macos - Mac OS X 上的免费磁盘空间栏

转载 作者:行者123 更新时间:2023-12-03 16:41:55 25 4
gpt4 key购买 nike

你们中有人知道是否有这样的控件可以在您自己的项目中使用吗?就像iTunes“已用空间”或Mac OS X“已用磁盘空格键”一样? enter image description here

最佳答案

这通常是自定义控件。

这种事情通常是通过创建 NSView 的子类并重写 drawRect: 方法来创建自定义组件来完成的。

然后您可以创建形状并按照您想要的方式填充。
引用Cocoa Drawing Guide了解更多信息和示例。

帮助您入门的基本示例:

- ( void )drawRect: ( NSRect )rect
{
NSBezierPath * path;
NSGradient * gradient;
CGFloat radius;

path = [ NSBezierPath bezierPathWithRoundedRect: rect xRadius: 2.0 yRadius: 2.0 ];
gradient = [ [ NSGradient alloc ] initWithColorsAndLocations: [ NSColor whiteColor ], 0.0,
[ NSColor blackColor ], 1.0,
nil
];

[ gradient drawInBezierPath: path angle: -90 ];
[ gradient release ];
}

关于macos - Mac OS X 上的免费磁盘空间栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16147724/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com