Reducing the size of UISwitch in Xamarin Forms does not work

旧时模样 提交于 2021-02-11 18:22:51

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!