减小 Xamarin Forms 中 UISwitch 的大小不起作用 [英] Reducing the size of UISwitch in Xamarin Forms does not work

查看:34
本文介绍了减小 Xamarin Forms 中 UISwitch 的大小不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Xamarin Forms 中,我为 Switch 创建了一个自定义渲染器.在 iOS 上,我更新了缩放变换以使其小于其默认大小:

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);

虽然这成功地调整了 Switch 的大小,但它并没有调整其边界框的大小.我该如何调整它的大小?

While this successfully resizes the Switch, it doesn't resize its bounding box. How can I resize it as well?

此处 Switch 的背景颜色在 XAML 中设置为红色.即使拇指较小,看起来仍然保持原始边界.

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.

推荐答案

您可以使用 Xamarin.Forms 中 Switch 的 Scale 属性:

You can use the Scale property of Switch in Xamarin.Forms:

   <Switch OnColor="Orange" Scale="0.75" BackgroundColor="Red"
    ThumbColor="Green" />

这篇关于减小 Xamarin Forms 中 UISwitch 的大小不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆