internal static UIView GetTrackSubview(this UISwitch uISwitch) { UIView uIView; if (NativeVersion.IsAtLeast(13)) { uIView = uISwitch.Subviews[0].Subviews[0]; } else { uIView = uISwitch.Subviews[0].Subviews[0].Subviews[0]; } return(uIView); }
public static void UpdateTrackColor(this UISwitch uiSwitch, ISwitch view, UIColor?defaultOnTrackColor, UIColor?defaultOffTrackColor) { if (view == null) { return; } if (view.TrackColor == Forms.Color.Default) { uiSwitch.OnTintColor = defaultOnTrackColor; } else { uiSwitch.OnTintColor = view.TrackColor.ToNative(); } UIView uIView; if (NativeVersion.IsAtLeast(13)) { uIView = uiSwitch.Subviews[0].Subviews[0]; } else { uIView = uiSwitch.Subviews[0].Subviews[0].Subviews[0]; } if (view.TrackColor == Forms.Color.Default) { uIView.BackgroundColor = defaultOffTrackColor; } else { uIView.BackgroundColor = uiSwitch.OnTintColor; } }