atomikpanda
atomikpanda

Reputation: 1886

Get Alpha Value Objective-C

How would I get the alpha value of a NSBox and Use it in an if statement?

I want to check the alpha of an NSBox if the value is equal to 0 then do something.

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

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

    }
}

Upvotes: 1

Views: 442

Answers (3)

Alexander Mistakidis
Alexander Mistakidis

Reputation: 3130

[Preferences alpha] == 0.0f

Should be what you're looking for

Upvotes: 0

atomikpanda
atomikpanda

Reputation: 1886

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.

Upvotes: 0

houbysoft
houbysoft

Reputation: 33430

Do you want

if ([Preferences alphaValue] == 1.0)

or something?

You need to explain what you want to do more clearly.

Upvotes: 1

Related Questions