【问题标题】:NSProgressIndicator - white cornersNSProgressIndicator - 白角
【发布时间】:2014-01-26 11:30:40
【问题描述】:

我正在使用https://github.com/kelan/yrk-spinning-progress-indicator 来获得一个白色的微调器。请注意,这不是 NSProgressIndicator 的子类,而是自定义的 NSView。

问题是这个自定义视图的角显示为白色,而不仅仅是一个清晰的背景。你可以在这张图片中看到这一点:

这是我的代码:

[_statusProgressIndicator setColor:[NSColor whiteColor]];
[_statusProgressIndicator setIndeterminate:YES];
[_statusProgressIndicator setBackgroundColor:[NSColor clearColor]];
[_statusProgressIndicator setDrawsBackground:YES];
[_statusProgressIndicator startAnimation:self];

我也试过了:

[_statusProgressIndicator setDrawsBackground:NO];

但效果是一样的。

关于如何解决这个问题的任何想法?

【问题讨论】:

    标签: objective-c cocoa nsview nsprogressindicator


    【解决方案1】:

    我下载了代码并运行了示例,原始代码提供的微调器中不存在圆角。

    我注意到您的图像中包含微调器的视图也有圆角?您是否在 setCornerRadius: 方法中使用基于层的视图?

    如果是这样,看起来微调器子视图也设置了该属性,因为看起来微调器和包含的视图具有相同大小的圆角。

    尝试专门将微调器视图的角半径设置为 0?

    【讨论】:

    • 嗨,这很有趣。我使用 MDBorderlessWindow ( github.com/NSGod/BlackBorderlessWindow ) 作为 superView - 它确实: NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect:frame xRadius:6.0 yRadius:6.0] 但仅此而已。微调器会: [NSBezierPath fillRect:[self bounds]]; - 我应该改变什么?
    • 在 MDBorderlessWindow 代码更改:[NSBezierPath bezierPathWithRoundedRect:frame xRadius:6.0 yRadius:6.0][NSBezierPath bezierPathWithRoundedRect:self.frame xRadius:6.0 yRadius:6.0] 该函数中的 drawRect 例程确实应该将传入参数命名为 rectdirtyRect 而不是 frame。当您的微调器更新并且底层窗口想要更新时,它会在脏矩形中绘制圆角,而不仅仅是在实际的窗口框架中。
    • 另外,在我的系统 (10.9.1) 上,黑色无边框窗口有白色角,它们应该是透明的,而且窗口也不能通过单击和拖动来移动。
    • 谢谢!这解决了它:-)另外,由于添加 [self setBackgroundColor:[NSColor clearColor]]; 我没有得到白色角落在 MDBorderlessWindow.m 和 [self setMovableByWindowBackground:YES];负责移动窗口。
    • 啊,太好了,我打算建议这两件事,因为我也在为我的圆角无标题启动画面做这件事!很高兴我能提供帮助,编码愉快! :)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-06-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多