jeudi 9 février 2017

Is using UIView.Animate in a ViewRenderer possible?

Vote count: 0

I tried to make some simple animations in a ViewRenderer but its not working at all. I need this in a Renderer because I cannot use the Animations in Forms in this case. This is a minimized Renderer to show what I have tried:

[assembly: ExportRenderer(typeof(AnimationTest.FeedbackView), typeof(AnimationTest.iOS.FeedbackViewRenderer))]
namespace AnimationTest.iOS
{
public class FeedbackViewRenderer : ViewRenderer
{

    UILabel Label;

    public FeedbackViewRenderer()
    {
    }

    protected override void OnElementChanged(ElementChangedEventArgs<View> e)
    {
        base.OnElementChanged(e);

        if (e.NewElement != null)
        {
            SetNativeControl(GetView("TEST"));
            Decay();
        }
    }

    void Decay()
    {
        UIView.Animate(333, 2000, UIViewAnimationOptions.CurveEaseIn, () =>
        {
            Label.Layer.Opacity = 0;
        }, () =>
        {
            Label.RemoveFromSuperview();
        });
    }

    UIView GetView(string text)
    {
        var view = new UIView();
        Label = new UILabel
        {
            BackgroundColor = UIColor.Black,
            Text = text,
            TextColor = UIColor.Red
        };
        view.Add(Label);
        return view;
    }

    public override void LayoutSubviews()
    {
        base.LayoutSubviews();
        Control.Frame = new CGRect(new CGPoint(), Frame.Size);
        Label.Frame = Control.Frame;
    }
}
}

asked 42 secs ago

Let's block ads! (Why?)



Is using UIView.Animate in a ViewRenderer possible?

Aucun commentaire:

Enregistrer un commentaire