2 Replies Latest reply: Aug 10, 2008 5:33 AM by Mario Kadastik
Mario Kadastik Level 1 Level 1 (10 points)
Well I have a screen (view controller to be more literal) that has a bunch of different views besides the most commonly used one. The way the user accesses these accessory views is by taping on any of the toolbar buttons that I have in different regions of the display. Now when he is in one of the accessory views I have made sure that the leftmost corner button takes him back to the main view. This button also shows the current day the player is in (take it as a turn based game) as this was the most obvious place to put the back link to so that I wouldn't lose more screen estate.

However as I was testing the game I noticed that it may not be obvious that this is the path back so I want to make this button start to blink/bloom whatever through some animation when the user switches to an accessory view. Now I know how to create animations, but there are two problems that I face:

1. I don't see a way to access the drawing layer of the UIBarButtonItem or it's view (if it has one) which is necessary for me to even do some animations.

2. If I put a second transparent view on top of this button and then animate that one (works), then I lose the button functionality as the view gets all the touches and doesn't pass them on to the button.

What would be the best solution to this dilemma. Is there a way to animate the button itself or if not, then is there a way to make a view ignore taps and pass them through to the view below it so that the button starts to work again.

MacBook Air, Mac OS X (10.5.4)
  • Mario Kadastik Level 1 Level 1 (10 points)
    Ok, I solved the view not allowing touches through point. Instead of letting the taps go through I catch the tap with touchesEnded and check if it's in the overlay view which is blinking. if they are I execute the change back to the main view and remove the blinking view from visible state.

    However this is not the most elegant way of doing it and I'd prefer to animate the UIBarButtonItem itself. Especially as I use the UIBarButtonItemStylePlain with a toolbar of black tint and I'd love to instead of customly trying to come up with an indication use instead the same white circle appearance every 0.7-1s that is drawn by the button when you tap on it. Any ideas on how to do that?
  • Mario Kadastik Level 1 Level 1 (10 points)
    Ok, I solved it myself :P I couldn't quite do it through the UIBarButtonItem, but what I did was to add a new layer to the main view which was about the size of the button and set the contents of that layer to be an image of a white gradient to transparency. I set the initial opacity to 0.0 and then when an accessory view is displayed I start animating the opacity property of that layer between 0.0 and 0.6. As the layer lets the touches through then the button works and in the process of redisplaying the main view I remove the animation from the layer. Voila, I have an identical look to it as I originally wanted. I will mark the question as solved, but if someone has a more elegant way of doing this then let me know.