如何在运行时在NSButton上独立地缩放轴

Reg*_*an 4 macos cocoa objective-c-runtime nsimage nsbutton

在Interface Builder中,您可以选择缩放按钮图像的方式,为"缩放"下拉菜单选择"轴独立","按比例缩小"等.如何在运行时访问或更改NSButton的此属性?

小智 10

您应该可以使用按钮的单元格来设置它:

NSButton *someButton;

NSButtonCell *someButtonCell = [someButton cell];
[someButtonCell setImageScaling:NSImageScaleAxesIndependently];
Run Code Online (Sandbox Code Playgroud)

有关图像缩放选项的列表,请参见此处.