iOSPawan iOSPawan - 1 year ago 112
iOS Question

on Disabale UIButton

when disable button. opacity reduced to 50% .is there any way to reduce opacity to 25%

Answer Source

I would subclass UIButton and override the setEnabled: method to something like this:

- (void) setEnabled:(BOOL)enabled {
    NSLog(@"Button enabled = %d", enabled);
    [super setEnabled:enabled];

    UIColor *color = self.backgroundColor;
    if (!self.isEnabled) {
        self.backgroundColor = [color colorWithAlphaComponent:0.75];
    } else {
        self.backgroundColor = [color colorWithAlphaComponent:1.0];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download