I've got the basics of my app working using the standard uislider but I want to create a custom slider using custom images and I want it to be vertical. Are there any examples of any part of this for xamarin ios?
or even just an example on creating any custom control? Or a control that inherits one of the standard controls..... anyone?
You can transform the slider. The following example will place the minimum value to the top. Use Math.Pi * 0.5f to put it to the bottom:
var slider = new UISlider(...);
slider.Transform = CGAffineTransformation.MakeRotation(Math.Pi * -0.5f);
Alternatively, you can implement your own by placing a knob like thing on the screen and add a gesture recognizer to it.
I achieved the following slider:
Using this code:
UISlider textColorSlider = new UISlider(new RectangleF(100, 100, 205, 28));
textColorSlider.BackgroundColor = UIColor.Clear;
textColorSlider.MinimumTrackTintColor = UIColor.Clear;
textColorSlider.MaximumTrackTintColor = UIColor.Clear;
textColorSlider.ThumbTintColor = UIColor.White;
UIImageView image = new UIImageView(new RectangleF(0,0, textSizeSlider.Frame.Width, textSizeSlider.Frame.Height));
image.Image = UIImage.FromFile("Images/Common/textColorBG.png");
I don't know if this is the most efficient method (probably not) but it did what I needed.
textColorBG.png is an image with rounded ends containing the color spectrum you see in the screenshot.
1pxTransparent.png is just that, a 1px by 1px transparent png .
You can use Krumelur's code to then rotate the slider.
Xamarin Inc., as a wholly-owned Microsoft subsidiary acting as a separate legal entity, adheres to the Microsoft Privacy Statement: Privacy & cookies