IOS - how to make transparent the visibility of the visibility of the navigation bar?

I am having some problems with certaing subviews alpha animation of my navigation bar. Here is the initial state of the panel:

enter image description here

Here is how far I have already managed:

enter image description here

The fact is that I need to make all these "stars", "new" and other round buttons transparent when the search is active (I need to reduce their alpha to zero). I am trying to make them transparent in the following delegate methods:

- (void)searchBarCancelButtonClicked:(UISearchBar *)asearchBar - (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar - (void)searchBarTextDidEndEditing:(UISearchBar *)searchBar - (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar 

In all of them I am doing exactly the same code:

 //parent is just a pointer of a search delegate, which points to view controller for (UIView * someViewToFade in parent.navigationController.navigationBar.subviews) { if (someViewToFade.tag == 88 || someViewToFade.tag == 11) { NSLog("someViewToFade.alpha before changes = %f", someViewToFade.alpha); someViewToFade.alpha = 0.0; //or 1.0, depending on the method } } 

However, I could not achieve the desired result this way, although I get the correct alpha values ​​in this NSLog, the buttons do not disappear at all. Are there any suggestions on what I can do wrong?

EDIT 1:

I think I should add some description of the view hierarchy in my case. Well, I have a UISegmentedConrol that contains these round buttons, as well as two UIImageViews, a background for segmented control and a triangle pointer. All these views are added to the navigation bar when it is in view mode. There is also a rectangular view that contains the search bar, and is also added as a subzone to the navigation bar later, so this is a top view in the hierarchy. In addition, I animate my searchBar by simply animating the frame of my supervisor (expanding or reducing it when the events above occur in the delegate). I hope I have provided all the necessary information.

+7
source share
2 answers

It has been a while since I programmed ios. It is possible that even if you set alpha, but do not cause a redraw. [UIView setNeedsDisplay] may help update the drawing in the next drawing cycle.

For reference: What is the most reliable way to get UIView to redraw?

+1
source

1) This is a problem with updating the user interface, write this statement after any user interface update code.

  [[NSRunLoop currentRunLoop] runUntilDate:[NSDate date]]; 

This will update your GUI.

or

2) use the selector in the main thread and update your user interface in the selection method.

  [self performSelectorOnMainThread:@selector(UpdateUIMethod) withObject:self waitUntilDone:NO]; 
+1
source

All Articles