我正在尝试将图像放入使用Xamarin iOS进行文本处理的文本中,并且图像的确显示还可以,但是由于其卡在文本字段的左边缘,我无法弄清楚如何在图像的左侧放置边距。下面是代码和结果。我在这里想念什么?
var imageView = new UIImageView(UIImage.FromBundle("xyz.png"))
{
Frame = new RectangleF(1,1,20,20);
};
Tf1.LeftViewMode = UITextFieldViewMode.Always;
Tf1.LeftView = imageView;
您可以执行以下操作来获得要实现的缩进效果,方法是创建另一个UIView,然后将UIImageView放在具有偏移量的现有UIView中,例如以下示例:
var imageView = new UIImageView(UIImage.FromBundle("xyz.png"))
{
// Indent it 10 pixels from the left.
Frame = new RectangleF(10,0,20,20)
};
UIView objLeftView = new UIView(new Rectangle(0,0,30,20));
ojLeftView.AddSubview(imageView);
然后在UITextField上将LeftView设置为:
objUITextField.LeftViewMode = UITextFieldViewMode.Always;
objUITextField.LeftView = objLeftView;
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句