Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 13 Animating View Not Changing Frame

I have an app which is compiled in Xcode 10 on iOS 13 simulator. In one view there is a "tray" view which shows from the bottom when tapped, in iOS 12 it works perfectly, in iOS 13, the tap is calling the method, but the changes to the frame are not saving - I have included outputs from the debugger in comments so you can see what the outputs of the frame values are;

- (void) userClickActivityTray: (UITapGestureRecognizer *) gestureRecognizer {
if(self.activityTrayShown) {
    /*
     (lldb) po self.activityTrayContainerView.frame
     (origin = (x = 0, y = 792), size = (width = 414, height = 104))
     */
    [self hideActivityTray];
} else {
    if (!self.activityTrayViewInitialFrameComputed) {
        self.activityTrayViewInitialFrameComputed = YES;
        self.activityTrayInitialFrame = self.activityTrayContainerView.frame;
    }

    /*
     (lldb) po self.activityTrayContainerView.frame
     (origin = (x = 0, y = 638), size = (width = 414, height = 224))
     (origin = (x = 0, y = 638), size = (width = 414, height = 224))

     (lldb) po self.activityTrayInitialFrame
     (origin = (x = 0, y = 792), size = (width = 414, height = 104))
     (origin = (x = 0, y = 792), size = (width = 414, height = 104))

     (lldb)
     */

    [UIView animateWithDuration:0.25 animations:^{
        self.activityTrayContainerView.frame = CGRectMake(self.view.bounds.origin.x,
                                                          self.bottomView.frame.origin.y - self.activityTrayViewController.maximumHeight,
                                                          self.view.bounds.size.width,
                                                          self.activityTrayViewController.maximumHeight);

        self.activityTrayBackgroundView.alpha = 1.0;
        self.bottomView.alpha = self.dotsProgressView.alpha = 0;
    } completion:^(BOOL finished) {
        self.activityTrayShown = YES;
        /*
         (lldb) po self.activityTrayContainerView.frame
         (origin = (x = 0, y = 557), size = (width = 414, height = 305))
         (origin = (x = 0, y = 792), size = (width = 414, height = 104))
         */
    }];
}

}

like image 555
ColinMasters Avatar asked Aug 21 '19 18:08

ColinMasters


3 Answers

You can use yourview.layer.frame instead of yourview.frame It worked for me.

like image 187
Paul Ho Avatar answered Nov 18 '22 06:11

Paul Ho


Layout system in iOS 13 is different, we had the same issue and in our case by switching layout from automatic to Translates Mask Into Constraints fixed the issue.

enter image description here

like image 19
Amir.n3t Avatar answered Nov 18 '22 07:11

Amir.n3t


I had the same issue when moving to iOS13. In my case, the sizing constraints were overriding any change I was making to the frame, which was not the case on iOS12. For my app to work correctly, I had to also update the NSLayoutContraint just before the "animateWithDuration" block, so that the new frame coordinates stay compatible with the layout constraints. Hope that helps

like image 3
Frank Avatar answered Nov 18 '22 07:11

Frank