How to solve the problem of invalid UIView effect in iOS7
Recently I want to make a running horse lamp effect, so I wrote the following code for the running horse lamp effect... However, debugging found that the animation in iOS6 can be executed, but the animation in iOS7 is not executed, and the expected effect is not achieved.
[_scrollLabel sizeToFit]; CGRect frame = _scrollLabel.frame; frame.origin.x = 320; _scrollLabel.frame = frame; [UIView setAnimationsEnabled:YES]; [UIView beginAnimations:@"testAnimation" context:NULL]; [UIView setAnimationDuration:10.f]; [UIView setAnimationCurve:UIViewAnimationCurveLinear]; [UIView setAnimationDelegate:self]; [UIView setAnimationRepeatAutoreverses:NO]; [UIView setAnimationRepeatCount:999999]; frame = _scrollLabel.frame; frame.origin.x = -frame.size.width; NSLog(@"frame orgin:%f",frame.origin.x); _scrollLabel.frame = frame; [UIView commitAnimations];
Then I checked all kinds of information on the Internet and did not solve it... In the end, I found that this view controller is a present mode view, and the UIView that is modal under iOS7 has a problem... Replace present with push... However, push does not achieve the prensent effect, so it imitates the present and implements the present animation in the push view. The Code is as follows:
1. push
MCLotteryListViewController *list = [[MCLotteryListViewController alloc]init]; //list.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;// [self presentViewController:list animated:YES completion:^{// // }]; [UIView beginAnimations:nil context:NULL]; [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; [UIView setAnimationDuration:0.75]; [self.navigationController pushViewController:list animated:NO]; [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.navigationController.view cache:NO]; [UIView commitAnimations];Ii. pop
[UIView beginAnimations:nil context:NULL]; [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; [UIView setAnimationDuration:0.75]; [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.navigationController.view cache:NO]; [UIView commitAnimations]; [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDelay:0.375]; [self.navigationController popViewControllerAnimated:NO]; [UIView commitAnimations];
Reprinted, please note, correct the error!