更正 Xamarin 框架的阴影 ios
Correct shadows for the Xamarin frame ios
我为框架元素制作了一个自定义渲染阴影 - 一切都很好,结果证明阴影适合我,但是由于使用这个自定义渲染,我对 RadioButton 元素产生了不好的影响,我该如何编辑它渲染使单选按钮元素正常?
sample image
/// <summary>
/// Renderer to update all frames with better shadows matching material design standards
/// </summary>
public class MaterialFrameRenderer : FrameRenderer
{
public override void Draw(CGRect rect)
{
base.Draw(rect);
// Update shadow to match better material design standards of elevation
Layer.ShadowRadius = Element.CornerRadius;
Layer.ShadowColor = UIColor.Gray.CGColor;
Layer.ShadowOffset = new CGSize(2, 2);
Layer.ShadowOpacity = 0.40f;
Layer.ShadowPath = UIBezierPath.FromRect(Layer.Bounds).CGPath;
Layer.MasksToBounds = false;
}
}
RadioButton 渲染似乎出了问题,我们甚至无法在 iOS 上为 RadioButton 创建自定义渲染器,检查 https://forums.xamarin.com/discussion/comment/430069#Comment_430069。
我强烈建议您使用 Xamarin.Forms.InputKit 而不是 Xamarin RadioButton 。
挺好看的
xmlns:input="clr-namespace:Plugin.InputKit.Shared.Controls;assembly=Plugin.InputKit"
<Frame Margin="100" CornerRadius="20" >
<input:RadioButtonGroupView>
<input:RadioButton Text="Option 1" />
<input:RadioButton Text="Option 2" />
<input:RadioButton Text="Option 3" />
<input:RadioButton Text="Option 4" />
</input:RadioButtonGroupView>
</Frame>
</ContentPage.Content>
我为框架元素制作了一个自定义渲染阴影 - 一切都很好,结果证明阴影适合我,但是由于使用这个自定义渲染,我对 RadioButton 元素产生了不好的影响,我该如何编辑它渲染使单选按钮元素正常? sample image
/// <summary>
/// Renderer to update all frames with better shadows matching material design standards
/// </summary>
public class MaterialFrameRenderer : FrameRenderer
{
public override void Draw(CGRect rect)
{
base.Draw(rect);
// Update shadow to match better material design standards of elevation
Layer.ShadowRadius = Element.CornerRadius;
Layer.ShadowColor = UIColor.Gray.CGColor;
Layer.ShadowOffset = new CGSize(2, 2);
Layer.ShadowOpacity = 0.40f;
Layer.ShadowPath = UIBezierPath.FromRect(Layer.Bounds).CGPath;
Layer.MasksToBounds = false;
}
}
RadioButton 渲染似乎出了问题,我们甚至无法在 iOS 上为 RadioButton 创建自定义渲染器,检查 https://forums.xamarin.com/discussion/comment/430069#Comment_430069。
我强烈建议您使用 Xamarin.Forms.InputKit 而不是 Xamarin RadioButton 。
挺好看的
xmlns:input="clr-namespace:Plugin.InputKit.Shared.Controls;assembly=Plugin.InputKit"
<Frame Margin="100" CornerRadius="20" >
<input:RadioButtonGroupView>
<input:RadioButton Text="Option 1" />
<input:RadioButton Text="Option 2" />
<input:RadioButton Text="Option 3" />
<input:RadioButton Text="Option 4" />
</input:RadioButtonGroupView>
</Frame>
</ContentPage.Content>