Search code examples
iosobjective-cuislider

UISliders overlap after transforming


I'm currently trying to create four vertical sliders in Objective-C. I'm able to rotate them using CGAffineTransform, but right now each slider is stacked on top of one another. How do you change the coordinates of the sliders so this doesn't happen?

Below is my code for rotating the sliders:

CGAffineTransform trans1 = CGAffineTransformMakeRotation(M_PI * 1.5);
_grainPitchSlider.transform = trans1;

CGAffineTransform trans2 = CGAffineTransformMakeRotation(M_PI * 1.5);
_grainOffsetSlider.transform = trans2;

CGAffineTransform trans3 = CGAffineTransformMakeRotation(M_PI * 1.5);
_grainDensitySlider.transform = trans3;

CGAffineTransform trans4 = CGAffineTransformMakeRotation(M_PI * 1.5);
_grainDurationSlider.transform = trans4;

Solution

  • Simply set the "center" of each slider, i.e. _grainPitchSlider.center = CGPointMake(x, y);