我无法找到以编程方式设置NSProgressIndicator高度的方法。
到目前为止我的尝试是:
NSProgressIndicator *ind = [[NSProgressIndicator alloc] init];
[ind setStyle: NSProgressIndicatorBarStyle];
// Height does not change height of the actual indicator
[ind setFrame: NSMakeRect(0, 0, 100, 50)];
[ind setBounds: NSMakeRect(0, 0, 100, 50)];
//[ind setControlSize: 0]; does only make it smaller, not bigger
[view addSubview: ind];我在文档中找到了NSProgressIndicatorBarStyle枚举,但找不到指定厚度的方法。
这里有一个描述我的问题的屏幕截图:(layer有一个红色的背景,以更好地理解):

在使用NSButton类时也会发生这种情况。有办法解决这个问题吗?
发布于 2014-09-14 14:04:29
在iOS中,由于框架限制,不能仅仅更改进度指示器的高度就可以更改其框架。但是,您应该能够实现相同的结果,处理转换。
_indicator.transform = CGAffineTransformMakeScale(1.0f, 0.6f);编辑:我刚在Mac上试过
_indicator.layer.transform = CATransform3DMakeScale(1.0f, 0.6f, 0.0f);而且它不起作用,所以它不像iOS,很可能是因为它是如何在Cocoa上实现的(就像Ken建议的)。我改变高度的唯一方法是使用controlSize,但我认为它不适合您的需要(因为它不允许您指定点数)。
[_indicator setControlSize:NSMiniControlSize]; // or NSSmallControlSize您应该能够通过子类NSProgressIndicator和重写drawRect来使用任意的框架,此时我的建议是环顾四周找一些可以扩展的东西供您使用,比如这个https://www.cocoacontrols.com/controls/lbprogressbar。
发布于 2017-04-30 22:56:34
在IB里你可以
这也可以通过编程方式添加,只需google就可以将内容筛选器添加到NSView中。
https://stackoverflow.com/questions/25833508
复制相似问题