简体   繁体   中英

UIView animation for multi views

I am trying to make animation for two views like this:

CGAffineTransform transform = CGAffineTransformMakeRotation(M_PI_2);
CGRect rect = self.oneView.frame;
rect.origin.y =  10;

[UIView animateWithDuration:0.5 delay:0.0 options:UIViewAnimationOptionCurveLinear animations:^{

    self.oneView.frame = rect;
    self.buttonView.transform = transform;

} completion:^(BOOL finished) {
    ...
}];

But only buttonView has rotated. OneView stays in place. But if I comment

//self.buttonView.transform = transform;

OneView has moved.

rect.origin.y = 10; is probably giving you a warning because you can't write directly to a CGRect .

You'll have to do rect = CGRectMake(rect.origin.x, 10.0f, rect.size.width, rect.size.height) .

What is the relationship between oneView and buttonView? If oneView is a child of buttonView, then this will be an expected effect.

Have you tried to run these animations from 2 separate calls?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM