【问题标题】:Get Alpha Value Objective-C获取 Alpha 值 Objective-C
【发布时间】:2012-07-07 05:10:50
【问题描述】:

如何获取 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];

    }
}

【问题讨论】:

    标签: ios objective-c if-statement alpha nsbox


    【解决方案1】:

    你想要

    if ([Preferences alphaValue] == 1.0)
    

    还是什么?

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

    【讨论】:

    • 是的。如果值等于 0,我想检查 NSBox 的 alpha 然后做点什么。
    • @s0ulp1xel: 好吧,只要检查一下你的值是否 == 0...?我一定是错过了什么。
    【解决方案2】:

    if ([PreferencesButton state]== 0) {

     [[[[Preferences subviews] objectAtIndex:0] animator] setAlphaValue:0.0];
    
    } 别的 {
    
        [[[[Preferences subviews] objectAtIndex:0] animator] setAlphaValue:1];
    }
    

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

    【讨论】:

      【解决方案3】:

      [Preferences alpha] == 0.0f

      应该是你要找的

      【讨论】:

        猜你喜欢
        • 2013-12-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-08-05
        • 2013-03-15
        • 2012-06-30
        • 2017-06-16
        相关资源
        最近更新 更多