xamarin.ios - How to assign Background Image to an entry in xamarin forms for ios -
i trying add background image entry in xamarin forms , wrote code rendering in ios , android. android working , ios not working. here sharing rendering code ios:
[assembly: exportrenderer (typeof(extendedusername), typeof(renderingentryuname))] namespace ifind.ios { public class renderingentryuname: entryrenderer { // override onelementchanged method can tweak renderer post-initial setup protected override void onelementchanged(elementchangedeventargs<entry> e) { base.onelementchanged(e); if (control != null) { control.textalignment=uitextalignment.center; uiimage img=uiimage.fromfile("images/newimg.jpg"); control.background=img } } } }
by default uitextentry
used forms entry
have border style set uitextborderstyle.roundedrect
, background ignored.
set border style none , image show up:
if (control != null) { control.borderstyle = uitextborderstyle.none; control.textalignment=uitextalignment.center; uiimage img=uiimage.fromfile("images/newimg.jpg"); control.background=img }
if value set uitextborderstyleroundedrect style, custom background image associated text field ignored.
ref: uitextfield
Comments
Post a Comment