gpt4 book ai didi

c# - 如何在 PickerRenderer xamarin forms IOS 中从右侧填充箭头

转载 作者:太空宇宙 更新时间:2023-11-03 19:46:29 26 4
gpt4 key购买 nike

public class CustomPickerRenderer : PickerRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.Picker> e)
{
base.OnElementChanged(e);
if (this.Control != null)
{
var downarrow = UIImage.FromBundle("your image");
var textField = this.Control;
textField.RightViewMode = UITextFieldViewMode.Always;
textField.RightView = new UIImageView(downarrow);
}
}
}

我在 IOS 上使用 PickerRenderer,我想从右侧留出一些空间。如何从右侧留出填充?这里图片,请查看enter image description here

最佳答案

Xamarin 选择器箭头解决方法

除了@Pratik 帖子外,除非您为图像创建点击事件,否则单击箭头将不起作用。

XAML

            <Grid>
<Picker
x:Name="catPicker"
Title="Select Type"/>
<Image
Margin="5"
HorizontalOptions="End"
Source="down_arrow">
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="Arrow_OnTapped" />
</Image.GestureRecognizers>
</Image>
</Grid>

C#

    private void Arrow_OnTapped(object sender, EventArgs e)
{
catPicker.Focus();
}

关于c# - 如何在 PickerRenderer xamarin forms IOS 中从右侧填充箭头,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44945930/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com