2012-07-07 28 views
1

如何獲取NSBox的Alpha值並在if語句中使用它?獲取Alpha值Objective-C

我想檢查一個NSBox的alpha值是否等於0,然後做一些事情。

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

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

    } 
} 

回答

1

你想

if ([Preferences alphaValue] == 1.0) 

什麼?

你需要解釋你想做得更清楚。

+0

是。我想檢查一個NSBox的alpha值,如果該值等於0,那麼做一些事情。 – atomikpanda 2012-07-07 09:31:42

+0

@ s0ulp1xel:好吧,只需檢查您的值== 0 ...?我肯定錯過了什麼。 – houbysoft 2012-07-07 13:09:11

0

if ([PreferencesButton state]== 0) {

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

} else { 

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

I was using a toggle button and need to use the state of the button instead of the alpha of the preferences box.

0

[Preferences alpha] == 0.0f

應該是你在找什麼