I need to increase size of slider in the iOS app
created using Xamarin Forms
. I tried with following custom renderer that overrides LayoutSubviews
. It increases the size but there is an unacceptable size increase for the thumb. How to reduce the size of the thumb keeping the increased height of the slider?
It is possible in Android as shown here: Increase height of slider without affecting thumb in Android App
iOS References:
Custom UISlider - Increase "hot spot" size
Increasing a thumbs "click area" in UISlider
C# Custom Renderer
[assembly: ExportRenderer(typeof(MySlider), typeof(MySliderRenderer))]
namespace CustomRenderer.iOS
{
class MySliderRenderer : Xamarin.Forms.Platform.iOS.SliderRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Slider> e)
{
base.OnElementChanged(e);
Control.MinimumTrackTintColor = UIColor.FromRGB(0xE6, 0x00, 0x06);
Control.ThumbTintColor = UIColor.Red;
Control.MinimumTrackTintColor = UIColor.Orange;
Control.MaximumTrackTintColor = UIColor.Yellow;
//Control.SetThumbImage(UIImage.FromFile("myicon.png"), UIControlState.Normal);
}
public override void LayoutSubviews()
{
base.LayoutSubviews();
CGAffineTransform transform = CGAffineTransform.MakeScale(1f, 12.0f);
transform.TransformSize(this.Frame.Size);
this.Control.Transform = transform;
}
}
}
UPDATE - REFERENCES - Renderer
Customizing Control Rendering in Xamarin.Forms
Implementing a View - Rendering a platform-specific view
iOS range slider for Xamarin and Xamarin.Forms
Fullscreen Video Background Control for Xamarin.Forms