Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.95 KB | None | 0 0
  1. #import "ViewController.h"
  2.  
  3. @interface ViewController () {
  4.  
  5. UIBarButtonItem *addButton;
  6.  
  7. }
  8.  
  9. @end
  10.  
  11. @implementation ViewController
  12. @synthesize tableView;
  13. @synthesize textField;
  14.  
  15.  
  16. - (void)viewDidLoad {
  17. [super viewDidLoad];
  18.  
  19. addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addButtonPressed:)];
  20.  
  21. self.navigationItem.rightBarButtonItem = addButton;
  22.  
  23. txtField.hidden = YES;
  24.  
  25. }
  26. - (void)addButtonPressed:(id)sender
  27. {
  28.  
  29. txtField.hidden = NO;
  30.  
  31.  
  32. }
  33.  
  34.  
  35. @end
  36.  
  37. #import "ViewController.h"
  38.  
  39. @interface ViewController () {
  40. Bool isShowingTF;
  41. UIBarButtonItem *addButton;
  42.  
  43. }
  44.  
  45. @end
  46.  
  47. @implementation ViewController
  48. @synthesize tableView;
  49. @synthesize textField;
  50.  
  51.  
  52. - (void)viewDidLoad {
  53. [super viewDidLoad];
  54. isShowingTF = NO;
  55. addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addButtonPressed:)];
  56.  
  57. self.navigationItem.rightBarButtonItem = addButton;
  58.  
  59. txtField.hidden = YES;
  60.  
  61. }
  62. - (void)addButtonPressed:(id)sender
  63. {
  64.  
  65. if (isShowingTF) {
  66. txtField.hidden = YES;
  67. } else {
  68. txtField.hidden = NO;
  69. }
  70. isShowingTF = ! isShowingTF;
  71. }
  72.  
  73.  
  74. @end
  75.  
  76. @interface ViewController () {
  77.  
  78. UIBarButtonItem *addButton;
  79. NSString *GettouchStr;
  80. }
  81.  
  82. - (void)viewDidLoad {
  83. [super viewDidLoad];
  84.  
  85. addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addButtonPressed:)];
  86. self.navigationItem.rightBarButtonItem = addButton;
  87. txtField.hidden = YES;
  88.  
  89. GettouchStr=@"hidden";
  90.  
  91. }
  92.  
  93. - (void)addButtonPressed:(id)sender
  94. {
  95. if ([GettouchStr isEqualToString:@"hidden"])
  96. {
  97. [UIView animateWithDuration:0.3 animations:^{
  98. txtField.alpha = 1;
  99. } completion: ^(BOOL finished) {
  100.  
  101. txtField.hidden = NO;
  102. GettouchStr=@"UNhidden";
  103. }];
  104.  
  105.  
  106. }
  107. else
  108. {
  109.  
  110. [UIView animateWithDuration:0.3 animations:^{
  111. txtField.alpha = 0;
  112. } completion: ^(BOOL finished) {
  113. txtField.hidden = YES;
  114. GettouchStr=@"hidden";
  115.  
  116. }];
  117.  
  118.  
  119. }
  120.  
  121.  
  122. }
  123.  
  124. - (void)addButtonPressed:(id)sender
  125. {
  126. if ([GettouchStr isEqualToString:@"hidden"])
  127. {
  128.  
  129. txtField.alpha = 1;
  130. [UIView animateWithDuration:2.f delay:0.f options:UIViewAnimationOptionCurveEaseIn animations:^{
  131. txtField.alpha = 0;
  132. } completion:^(BOOL finished) {
  133. [UIView animateWithDuration:2.f delay:0.f options:UIViewAnimationOptionCurveEaseInOut animations:^{
  134. txtField.alpha = 1;
  135. txtField.hidden = NO;
  136. GettouchStr=@"UNhidden";
  137. } completion:nil];
  138. }];
  139.  
  140.  
  141.  
  142.  
  143.  
  144. }
  145. else
  146. {
  147. txtField.alpha = 0;
  148. [UIView animateWithDuration:2.f delay:0.f options:UIViewAnimationOptionCurveEaseIn animations:^{
  149. txtField.alpha = 1;
  150. } completion:^(BOOL finished) {
  151. [UIView animateWithDuration:2.f delay:0.f options:UIViewAnimationOptionCurveEaseInOut animations:^{
  152. txtField.alpha = 0;
  153. txtField.hidden = YES;
  154. GettouchStr=@"hidden";
  155. } completion:nil];
  156. }];
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163. }
  164.  
  165.  
  166. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement