I have two UIView (my bad one is UIViewa UIButton) and I am animating at the same time. Initially, I had a look and a container that would liven up just fine and work like a charm.
Now only one of my UIViews will move / animate in animateWithDuration, even if through debugging the frame of another view it says that it is in a position in which it is not.
CGRect rect = self.toggle.frame;
CGRect tabRect = self.tabButton.frame;
rect.origin.x = rect.origin.x - rect.size.width;
NSLog(@"%f Before",tabRect.origin.x);
tabRect.origin.x = tabRect.origin.x - rect.size.width;
NSLog(@"%f After", tabRect.origin.x);
[UIView animateWithDuration:0.3 animations:^{
self.toggle.frame = rect;
self.tabButton.frame = tabRect;
}];
NSLog(@"%f AfterAnimation", tabButton.frame.origin.x);
The switch view moves fine, but the view is tabButtonnot animated or moved. It is strange that both debug codes "After" and "AfterAnimation" return the same value, which suggests that the frame really moved. Is there a particular reason why this will not work if toggleis UIViewthat it will work as UIContainerView?
Please note that if I delete the line
self.toggle.frame = rect;
tabButtonwill animate correctly, but if I move toggle, tabButtonit won’t move regardless of whether it is the first in an animation block or a second.
Edit: I tried moving them into separate blocks and changing the center point, not the frame, but to no avail. It seems that if the view togglemoves, tabButtonit will not move.
2: . {
tabButton bg , bg - .

: (toggle )

: toggle tabButton

: self.toggle.frame = rect (tabButton , toggle )
}
3: , . {
, toggle , , tabButton . , tabButton toggle / , , .
}
4: {
tabButton tabButton.frame = CGRectMake(10,10,100,100), View , .
}
/TL;DR, .
toggle - ToggleDraw, UIView, .
tabButton UIButton, IB viewController
toggle tabButton self.view
- , ,
,toggle tabButton