iPhone location button

后端 未结 8 585
南方客
南方客 2021-02-05 23:28

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 b

相关标签:
8条回答
  • 2021-02-06 00:13

    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];
    
    0 讨论(0)
  • 2021-02-06 00:14
    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.

    0 讨论(0)
  • 2021-02-06 00:17

    http://glyphish.com/ icon library has location button available.

    0 讨论(0)
  • 2021-02-06 00:20

    Have a look at https://github.com/myell0w/MTLocation

    Idle Mode Searching Mode Receiving Location Updates Mode Receiving Heading Updates Mode

    I mimiced Google Maps' Locate Me - Button, including 4 different states and the animation that is done when switching between states.

    0 讨论(0)
  • 2021-02-06 00:24

    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.

    0 讨论(0)
  • 2021-02-06 00:24

    (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"];
    
    0 讨论(0)
提交回复
热议问题