Guest User

Untitled

a guest
May 11th, 2012
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. How can I make this snippet prettier/better/less lines?
  2. -(void)showRivBoxWithAnimtation:(BOOL)yesno {
  3. if(yesno) {
  4. [UIView beginAnimations:nil context:NULL];
  5. [UIView setAnimationDuration:0.2];
  6. if ([self alpha] > 0) {
  7. [self setAlpha:0.0];
  8. [appDelegate.JSONparser setDelegate:self.delegate]; //Give back the JSONparser to the parent!
  9. } else {
  10. [self setAlpha:1.0];
  11. }
  12. [UIView setAnimationDelegate:self];
  13. [UIView setAnimationDidStopSelector:@selector(clearRivBoxContent:finished:context:)];
  14. [UIView commitAnimations];
  15. } else {
  16. if ([self alpha] > 0) {
  17. [self setAlpha:0.0];
  18. [appDelegate.JSONparser setDelegate:self.delegate]; //Give back the JSONparser to the parent!
  19. } else {
  20. [self setAlpha:1.0];
  21. }
  22. }
  23. }
  24.  
  25. -(void)showRivBoxWithAnimtation:(BOOL)yesno {
  26. [UIView animateWithDuration:yesno ? 0.2 : 0.0
  27. animations:^{
  28. if ([self alpha] > 0) {
  29. [self setAlpha:0.0];
  30. [appDelegate.JSONparser setDelegate:self.delegate]; //Give back the JSONparser to the parent!
  31. } else {
  32. [self setAlpha:1.0];
  33. }
  34. }
  35. completion:^(BOOL finished){
  36. if (finished) {
  37. // Do the stuff from clearRivBoxContent:finished:context:
  38. }
  39. }];
  40. }
  41.  
  42. -(void)showRivBoxWithAnimtation:(BOOL)yesno {
  43. if ([self alpha] > 0) {
  44. [self setAlpha:0.0];
  45. [appDelegate.JSONparser setDelegate:self.delegate]; //Give back the JSONparser to the parent!
  46. } else {
  47. [self setAlpha:1.0];
  48. }
  49.  
  50. if(yesno) {
  51. [UIView beginAnimations:nil context:NULL];
  52. [UIView setAnimationDuration:0.2];
  53. [UIView setAnimationDelegate:self];
  54. [UIView setAnimationDidStopSelector:@selector(clearRivBoxContent:finished:context:)];
  55. [UIView commitAnimations];
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment