Try to move and resize a UIView after user make actions at screen #iOS

Hello Guys

We try build a Video Call Screen like whatsapp but we have a little problem when try to MOVE and RESIZE a UIVIEW at iOS.

When we change the UIVIEW Frame it changes its place, but it does not resize. We are using Xamarin.Forms with Custom Renderer.

On Android we can make it work using the Animations class.

Anyone can help? Follow part of code:

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

            if (Control == null)
            {
                videosViews = new UIView(Bounds)
                {
                    BackgroundColor = Xamarin.Forms.Color.Transparent.ToUIColor(),
                };

                SetNativeControl(videosViews);
            };

            if (this.Element == null) return;

            myVideo = new PortSIPVideoRenderView()
            {
                Frame = new CoreGraphics.CGRect(UIScreen.MainScreen.Bounds.Width - 155, 30, 135, 200),
                //AutoresizingMask = UIViewAutoresizing.None
            };

            remoteVideo = new PortSIPVideoRenderView()
            {
                Frame = new CoreGraphics.CGRect(0, 0, UIScreen.MainScreen.Bounds.Width, UIScreen.MainScreen.Bounds.Height)
                //AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight

            };

            Element.OnCallStart += (sender, evArgs) =>
            {
  var newFrame = myVideo.Frame;
                newFrame.X = UIScreen.MainScreen.Bounds.Width - 155;
                newFrame.Y = 30;
                newFrame.Width = 135;
                newFrame.Height = 200;
                myVideo.Frame = newFrame;
                //newFrame.Size = new CoreGraphics.CGSize(135, 200);
                //myVideo.RemoveConstraints(myVideo.Constraints);
                //myVideo.AutosizesSubviews = true;
                //myVideo.Layer.Frame = new CoreGraphics.CGRect(UIScreen.MainScreen.Bounds.Width - 155, 30, 20, 20);
                //myVideo.LayoutIfNeeded();
                //myVideo.LayoutSubviews();
                //myVideo.UpdateConstraints();          
             };



            myVideo.initVideoRender();
            remoteVideo.initVideoRender();

            videosViews.AddSubview(remoteVideo);
            videosViews.AddSubview(myVideo);
        }

Posts

Sign In or Register to comment.