We experimentally demonstrate that critical Casimir forces in colloidal systems can be continuously tuned by the choice of boundary conditions. The interaction potential of a colloidal particle in a mixture of water and 2,6-lutidine has been measured above a substrate with a gradient in its preferential adsorption properties for the mixture's components. We find that the interaction potentials at constant temperature but different positions relative to the gradient continuously change from attraction to repulsion. This demonstrates that critical Casimir forces respond not only to minute temperature changes but also to small changes in the surface properties.