Search code examples
iosxamarinpixate

Disabling a control with Pixate Freestyle


I have a UIButton with the following css

button {
    size: 50 100;
    color: #FF0000;
}

But I want to disable the button based on a style like maybe:

button {
    size: 50 100;
    color: #FF0000;
    enabled: true;
}

Does anyone know how to accomplish or add an extension method to enable this?


Solution

  • I don't think there are enabled or disabled pseudo-classes available for UIButton. What you could potentially do instead is detect the button state and assign a styleClass dynamically like this:

    #import <PixateFreestyle/PixateFreestyle.h>
    
    UIButton *button = [UIButton new];
    
    if(button.enabled){
      button.styleClass = @"myButton";
    }else{
      button.styleClass = @"myButtonDisabled";
    }
    

    ...and then your CSS would be:

    .myButton {
        /* Default button styles */
    }
    .myButtonDisabled {
        /* Disabled button styles */
    }
    

    I hope that helps. Good luck.