0

Here is the code for the custom Renderer in iOS. .
my point is i want the text to be under then image, i tried XLabs ImageButton but it's looks like they are not working with the new XamarinForms anymore ....

Xamarin.iOS... .

/* .

Blockquote

public class ButtonCustomRendererIOS : ButtonRenderer
    {
        public ButtonCustomRendererIOS()
        {
        }

        protected override void OnElementChanged(ElementChangedEventArgs<Button> e)
        {
            base.OnElementChanged(e);
            if(e.NewElement !=null)
            {
                if (Control != null)
                {

#if DEBUG
                    Control.HorizontalAlignment = UIControlContentHorizontalAlignment.Center;
                    Control.VerticalAlignment   =   UIControlContentVerticalAlignment.Center;

                    Control.Layer.CornerRadius = 15;
                    Control.Layer.BorderWidth = 5;
                    Control.Layer.BorderColor = Color.Red.ToCGColor();

                    var uiImage = UIImage.FromFile(((Button)e.NewElement).Image.File);
                    var lineHeight = Control.TitleLabel.Font.LineHeight;
                    Control.ImageEdgeInsets = new UIEdgeInsets(-lineHeight, uiImage.Size.Width + (uiImage.Size.Width / 2), 0, 0);
                    Control.TitleEdgeInsets = new UIEdgeInsets(uiImage.Size.Height, -uiImage.Size.Width, 0, 0);
                    uiImage.Dispose();
#endif


                }
            }
        }
    }

Blockquote

*/ .

Hamadda
  • 1
  • 1
  • the XAML is not really relevant. It would be more helpful to post the code of your renderer, and perhaps a screenshot illustrating the incorrect behavior – Jason May 30 '18 at 01:16
  • The same code for IOS at this link https://stackoverflow.com/questions/38106050/xamarin-custom-buttonrenderer-text-under-image – Hamadda May 30 '18 at 01:35
  • Just use a `button`... `` – Trevor May 30 '18 at 01:35
  • The problem specially with iOS on if the text wider than the image the image moves to the right but not goes to newline. – Hamadda May 30 '18 at 02:09
  • I am confused, are you working with Xamarin or iOS? You keep mentioning iOS related issues, is the .Net and Android button working for you then? – Trevor May 30 '18 at 02:42
  • Am working with XamarinForms... the result at the Android is fine. – Hamadda May 30 '18 at 17:03

0 Answers0