Reputation: 283
Ya know the little location button in the lower-left corner of the Maps application? Does anybody know where I can find that? I looked in UIButtonType and UITabBarSystemItem but came up blank.
I'd prefer to use a system image or a system something-or-other, to help ensure consistency with other system functions.
Upvotes: 10
Views: 13722
Reputation: 1290
You can try using MKUserTrackingBarButtonItem It provides the same functionality as the track button on the Map app. Here is some same code.
MKUserTrackingBarButtonItem *trackButton = [[MKUserTrackingBarButtonItem alloc] initWithMapView:self.mapView];
NSMutableArray *items = [[NSMutableArray alloc] initWithArray:self.bottomToolbar.items];
[items insertObject:trackButton atIndex:0];
[self.bottomToolbar setItems:items];
Upvotes: 7
Reputation: 2200
Have a look at https://github.com/myell0w/MTLocation
I mimiced Google Maps' Locate Me - Button, including 4 different states and the animation that is done when switching between states.
Upvotes: 7
Reputation: 2700
Please note that in 4.0, the appearance of the "locate me" button in Maps.app button has changed. Further on, +[UIimage kitImageNamed:]
is gone, and calling -[UIBarbuttonItem initWithBarButtonSystemItem:]
with undocumented identifier 100 will return old-style graphics.
Upvotes: 3
Reputation: 1507
UIImage* img = [UIImage kitImageNamed:@"UIButtonBarLocate.png"];
// Get the location of the Documents directory
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) ;
NSString *imagePath = [paths objectAtIndex:0] ;
NSString *filename = @"test.png" ;
NSString *filepath = [NSString stringWithFormat:@"%@/%@", imagePath, filename] ;
// Save the image
NSData *imageData = [NSData dataWithData:UIImagePNGRepresentation(img)];
[imageData writeToFile:filepath atomically:YES];
use this sample of code to save it as a file that you'll be able to use in your project!
Hope this help.
Upvotes: 0
Reputation: 523574
(Warning: undocumented feature, will be rejected by AppStore, blah blah blah)
The location button can be accessed with
UIBarButtonItem* item = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:100
target:... action:...];
If you just want the image, save the result returned by
UIImage* img = [UIImage kitImageNamed:@"UIButtonBarLocate.png"];
Upvotes: 2
Reputation: 2306
http://glyphish.com/ icon library has location button available.
Upvotes: 1
Reputation: 5554
I created my own image, and Apple accepted it (in contrast of using the search image for zooming purposes).
Upvotes: 1
Reputation: 50318
I wouldn't be so sure that it's a system image. Many images/buttons in Apple's applications are specific to that application only, and this one looks to be that way.
Upvotes: 0