简体   繁体   English

NSToolbarItem图像缩放

[英]NSToolbarItem image scaling

Why is this happening: 为什么会这样:

As you can see, in the "Allowed Toolbar Items" the image looks fine for the "PHP" toolbar item, and when its actually in the toolbar, it scales weirdly. 正如您所看到的,在“允许的工具栏项”中,图像看起来很适合“PHP”工具栏项,当它实际位于工具栏中时,它会奇怪地缩放。

Thanks 谢谢

Found this in the documentation: 在文档中找到了这个:

The displayed resolution of an image item is dependent on the sizeMode of the toolbar. 显示的图像项分辨率取决于工具栏的sizeMode。 You should provide image representations specific to the default, regular and small size modes in a single image that supports multiple image representations such as icns or tiff. 您应该在支持多个图像表示(如icns或tiff)的单个图像中提供特定于默认,常规和小尺寸模式的图像表示。 The appropriate image representation is automatically displayed for the toolbar's current sizeMode. 将自动显示工具栏当前sizeMode的相应图像表示。 If an appropriate representation is not available, the toolbar scales the representation to the appropriate size for the current mode, at a cost in performance and appearance. 如果没有适当的表示,工具栏会将表示缩放到当前模式的适当大小,但会降低性能和外观的成本。 Images that are not square are scaled to fit. 非方形图像缩放以适合。 An image item's image is also scaled down and used in the image item's overflow menu item. 图像项目的图像也按比例缩小并在图像项目的溢出菜单项中使用。 (Emphasis added) (重点补充)

This seems you might want to try fiddling with the NSToolbarItem 's minSize and maxSize properties. 这似乎你可能想尝试摆弄NSToolbarItemminSizemaxSize属性。

I found it easier to drag an instance of "Image Well" (NSImageView) into the Toolbar. 我发现将“Image Well”(NSImageView)的实例拖到工具栏中更容易。 This allows setting appropriate dimensions (just add a minimum and maximum size and you can then set the desired scaling). 这允许设置适当的尺寸(只需添加最小和最大尺寸,然后您可以设置所需的比例)。

It is basically the same as dragging an instance of NSToolbarItem: it just automatically inserts a configurable NSImageView into a new NSToolbarItem. 它与拖动NSToolbarItem的实例基本相同:它只是自动将可配置的NSImageView插入到新的NSToolbarItem中。 So you can wire it to your Target/Actions as usual. 因此,您可以像往常一样将其连接到目标/操作。

Tipp: you can also drag NSSegmentedControls and other NSControls into the toolbar :-) Tipp:你也可以将NSSegmentedControls和其他NSControls拖到工具栏中:-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM