1

如何获取 NSBox 的 alpha 值并在 if 语句中使用它?

如果值等于 0,我想检查 NSBox 的 alpha 然后做点什么。

if ([Preferences alphaValue ==0]) {
        [[[[Preferences subviews] objectAtIndex:0] animator] setAlphaValue:0.0];

    } else {
        [[[[Preferences subviews] objectAtIndex:0] animator] setAlphaValue:1];

    }
}
4

3 回答 3

1

你想要

if ([Preferences alphaValue] == 1.0)

或者其他的东西?

你需要更清楚地解释你想要做什么。

于 2012-07-07T05:18:38.000 回答
0

if ([PreferencesButton state]== 0) {

    [[[[Preferences subviews] objectAtIndex:0] animator] setAlphaValue:0.0];

} else {

    [[[[Preferences subviews] objectAtIndex:0] animator] setAlphaValue:1];
}

我使用的是切换按钮,需要使用按钮的状态而不是首选项框的 alpha。

于 2012-07-07T15:58:25.033 回答
0

[Preferences alpha] == 0.0f

应该是你要找的

于 2015-06-25T21:22:16.850 回答