Adding a Forms ImageView from a iOS custom renderer is broken...

JoeBoothJoeBooth USMember ✭✭

I want to be able to add a Forms Image from within a custom renderer. On Android this code works fine; but not on iOS...

ImageSource imgSource = ResourceHelper.GetImageName("Bets", "Logo");
    Image img = new Image () {
        Source = imgSource,
        WidthRequest = 30,
        HeightRequest = 30,
        };

    var imgRenderer = new ImageRenderer();
    imgRenderer.SetElement (img);
    myAndroidCustomRendererView.AddView(imgRenderer);

Answers

  • JoeBoothJoeBooth USMember ✭✭

    figured it out - i need to use Layout() vs Width/HeightRequest to work on iOS & Android

    ImageSource imgSource = ResourceHelper.GetImageName("Bets", "Logo");
        Image img = new Image () {
            Source = imgSource,
            };
        img.Layout (new Rectangle(0,0,30,30));
    
        var imgRenderer = new ImageRenderer();
        imgRenderer.SetElement (img);
        myAndroidCustomRendererView.AddView(imgRenderer);
    
Sign In or Register to comment.