Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Updating iOS FrameRenderer on size change

$
0
0

Hey guys,
I need some help with my iOS FrameRenderer. How can I handle the update when the size is changing? I draw a shadow but when the size of the frame changes the shadow is not updated because the draw method is not called again. I tried to use the overrides SubviewAdded, OnElementChanged and OnElementPropertyChanged but had no luck with it. I use a Repeatable Stack within the Frame.

public class MaterialFrameRenderer : FrameRenderer
{
    public override void Draw(CGRect rect)
    {
        base.Draw(rect);
        Layer.ShadowRadius = materialFrame.Elevation;
        Layer.ShadowColor = UIColor.Gray.CGColor;
        Layer.ShadowOffset = new CGSize(2, 2);
        Layer.ShadowOpacity = 0.80f;
        Layer.ShadowPath = UIBezierPath.FromRect(Layer.Bounds).CGPath;
        Layer.MasksToBounds = false;
    }
}

Any kind of help is most appreciated. Thanks

Edit: Seems like it is some kind of timing problem. I now use the OnElementPropertyChanged override and a delay of 10ms and it is updating properly. But maybe there is a better way.


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>