alexrainman / SegmentedControl

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

how to change border radius?

Yashshree opened this issue · comments

Control is working fine for me. i want to increase border radius.

iOS:
Extend the renderer and update the corner radius of the native control.

[assembly: ExportRenderer(typeof(MyAppSegmentControl), typeof(SegmentControlRenderer))]
namespace MyApp.iOS.Renderers
{
    public class SegmentControlRenderer : SegmentedControl.FormsPlugin.iOS.SegmentedControlRenderer
    {
        protected override void OnElementChanged(ElementChangedEventArgs<SegmentedControl.FormsPlugin.Abstractions.SegmentedControl> e)
        {
            base.OnElementChanged(e);
            if (Control == null || e.NewElement == null) return;

            Control.Layer.CornerRadius = (float) <whatever>;
        }
    }
}

Android:
Create 2 drawables in your Resources\drawable folder named segmented_control_first_background.xml and segmented_control_last_background.xml. Copy the content from this repo into those files and update this line to desired radius:

<corners android:topLeftRadius="2sp" android:bottomLeftRadius="2sp" />