我一直在尝试最小化我的应用程序中的所有功能,但无法真正找到如何使这个功能更好,也许有人比我好多了? :)
-(void)showRivBoxWithAnimtation:(BOOL)yesno {
if(yesno) {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.2];
if ([self alpha] > 0) {
[self setAlpha:0.0];
[appDelegate.JSONparser setDelegate:self.delegate]; //Give back the JSONparser to the parent!
} else {
[self setAlpha:1.0];
}
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(clearRivBoxContent:finished:context:)];
[UIView commitAnimations];
} else {
if ([self alpha] > 0) {
[self setAlpha:0.0];
[appDelegate.JSONparser setDelegate:self.delegate]; //Give back the JSONparser to the parent!
} else {
[self setAlpha:1.0];
}
}
}
答案 0 :(得分:2)
这就是我要做的事情:
-(void)showRivBoxWithAnimtation:(BOOL)yesno {
[UIView animateWithDuration:yesno ? 0.2 : 0.0
animations:^{
if ([self alpha] > 0) {
[self setAlpha:0.0];
[appDelegate.JSONparser setDelegate:self.delegate]; //Give back the JSONparser to the parent!
} else {
[self setAlpha:1.0];
}
}
completion:^(BOOL finished){
if (finished) {
// Do the stuff from clearRivBoxContent:finished:context:
}
}];
}
答案 1 :(得分:0)
除非操作顺序不合适。 alpha是至关重要的;这可能是最小的。
-(void)showRivBoxWithAnimtation:(BOOL)yesno {
if ([self alpha] > 0) {
[self setAlpha:0.0];
[appDelegate.JSONparser setDelegate:self.delegate]; //Give back the JSONparser to the parent!
} else {
[self setAlpha:1.0];
}
if(yesno) {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.2];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(clearRivBoxContent:finished:context:)];
[UIView commitAnimations];
}
}