If you setup your custom field with a Radio Button to select either a Background Image or Background Color. This little Code Snippet will make it easy.
<?php
if ( get_sub_field( 'text_color_option' ) === 'green' ) {
$color_option = 'text-green';
} else {
$color_option = 'text-red';
}
?>
<?php
$backgroundType = get_sub_field( 'background_option' );
if ($backgroundType == 'image'){
$style = "background-image: url(" . (get_sub_field('background_image')) . ")";
} else { //it's a color
$style = "background-color: " . get_sub_field('background_color');
}
?>
Example:
<div class="<?php echo esc_attr( $color_option ); ?>" style="<?php echo esc_attr( $style )">
</div>