iOSPawan iOSPawan - 4 months ago 7
iOS Question

on Disabale UIButton

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

Answer

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];
    }
}
Comments