问题
I am trying to find out whether my animation runs and completed or else it is still in process??
animationImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320 , 480)];
animationImageView.animationImages = [[NSArray alloc] initWithObjects:[UIImage imageNamed:@"eg1"],[UIImage imageNamed:@"eg2"],[UIImage imageNamed:@"eg1"],[UIImage imageNamed:@"eg2"],[UIImage imageNamed:@"eg2"],[UIImage imageNamed:@"eg2"],[UIImage imageNamed:@"eg1"],[UIImage imageNamed:@"eg2"],[UIImage imageNamed:@"eg2"],[UIImage imageNamed:@"eg2"],[UIImage imageNamed:@"eg2"], nil];
animationImageView.animationDuration = 2.2f;
animationImageView.animationRepeatCount=1;
[self.view addSubview:animationImageView];
[animationImageView startAnimating];
Can anyone help me?
I am having UIview
over a container which holds UITableviewcontroller
, i given segue to my view controller from navigation controller. Now i would like to run my UIView
with navigation bar hidden. I tried with code but it is in vain either both views having navigation bar or both does not have.
I am working with storyboard.
Actually am using UIImageView
for "Splashscreen" purpose.
回答1:
try this
[UIView animateWithDuration:2.2f animations:^{
UIImageView *animationImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320 , 480)];
animationImageView.animationImages = [[NSArray alloc] initWithObjects:[UIImage imageNamed:@"eg1"],[UIImage imageNamed:@"eg2"],[UIImage imageNamed:@"eg1"],[UIImage imageNamed:@"eg2"],[UIImage imageNamed:@"eg2"],[UIImage imageNamed:@"eg2"],[UIImage imageNamed:@"eg1"],[UIImage imageNamed:@"eg2"],[UIImage imageNamed:@"eg2"],[UIImage imageNamed:@"eg2"],[UIImage imageNamed:@"eg2"], nil];
animationImageView.animationDuration = 2.2f;
animationImageView.animationRepeatCount=1;
[self.view addSubview:animationImageView];
[animationImageView startAnimating];
} completion:^(BOOL finished) {
NSLog(@"Finished");
}];
To find out animating or not
if ([YourAnimationImageView isAnimating]) {
NSLog(@"Yes animation in progress");
}
else{
NSLog(@"NO. animation has been stopped/finished");
}
来源:https://stackoverflow.com/questions/23805962/how-to-identify-animations-completed-or-not