问题
In Xamarin Forms, I created a custom renderer for Switch
. On iOS, I updated the scale transform to make it smaller than its default size:
Control.Transform = CGAffineTransform.MakeScale((float)0.75, (float)0.75);
While this successfully resizes the Switch
, it doesn't resize its bounding box. How can I resize it as well?
Here the background color of the Switch
is set to red in XAML. It looks like the original bounds are still being maintained even though the thumb is smaller.
回答1:
You can use the Scale
property of Switch in Xamarin.Forms:
<Switch OnColor="Orange" Scale="0.75" BackgroundColor="Red"
ThumbColor="Green" />
来源:https://stackoverflow.com/questions/60221344/reducing-the-size-of-uiswitch-in-xamarin-forms-does-not-work