views:

447

answers:

2

I would like to use or emulate a button like the gps button in the bottom left corner of the standard maps application on the iphone OS. The button behaves like a toggle button where gps is enabled or disabled depending on whether it is pushed and it may hold a small spinner component while the gps is finding your position.

Does anyone know if this component can be easily constructed using default components? If no, what would be the best way to develop such a component?

Is the crosshair/target icon a generic icon that I can re-use?

A: 

The button is just an image, you should be able to recreate it.

In order to do the tracking, I would look at this sample code: http://developer.apple.com/iphone/library/samplecode/LocateMe/index.html

It shows you how to get the GPS coordinates, then you can feed that data into a MKMapView.

christo16
The http://glyphish.com/ icon set has an image that closely resembles the "official" one. The icon is accessible, but through undocumented means, which will surely be flagged by apple.
Eric Schweichler
The icon is quite perfect.. thanks for that link! The core location framework is quite straightforward so I got that working already. Any ideas on how to make the spinner run inside a button? that's very custom behaviour isn't it?
xastor
You're going to want to subclass UIButton. It's definitely possible, you would use Core Animation to fade between the UIImage (crosshair) and UIActivityIndicatorView subviews. Some good info on subclassing a UIControl: http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIControl_Class/Reference/Reference.html#//apple_ref/occ/cl/UIControl
christo16
A: 

Apple's Spinner Button is hidden, but can be used with systemButton: 100

ream88