10

你知道地图应用程序左下角的小位置按钮吗?有人知道我在哪里可以找到那个吗?我查看了 UIButtonType 和 UITabBarSystemItem 但出现了空白。

我更喜欢使用系统映像或系统其他东西,以帮助确保与其他系统功能的一致性。

4

8 回答 8

7

看看https://github.com/myell0w/MTLocation

空闲模式 搜索模式 接收位置更新模式 接收航向更新模式

我模仿了 Google Maps 的 Locate Me - Button,包括 4 种不同的状态以及在状态之间切换时完成的动画。

于 2011-01-22T22:40:57.753 回答
7

您可以尝试使用MKUserTrackingBarButtonItem 它提供与地图应用程序上的跟踪按钮相同的功能。这是一些相同的代码。

MKUserTrackingBarButtonItem *trackButton = [[MKUserTrackingBarButtonItem alloc] initWithMapView:self.mapView];
NSMutableArray *items = [[NSMutableArray alloc] initWithArray:self.bottomToolbar.items];
[items insertObject:trackButton atIndex:0];
[self.bottomToolbar setItems:items];
于 2013-02-06T15:26:44.867 回答
3

请注意,在 4.0 中,Maps.app 按钮中“定位我”按钮的外观发生了变化。更进一步,+[UIimage kitImageNamed:]已经消失了,-[UIBarbuttonItem initWithBarButtonSystemItem:]使用未记录的标识符 100 调用将返回旧式图形。

于 2010-06-28T19:04:27.543 回答
2

(警告:未记录的功能,将被 AppStore 拒绝,等等等等)

位置按钮可以通过

UIBarButtonItem* item = [[UIBarButtonItem alloc]
                         initWithBarButtonSystemItem:100
                                              target:... action:...];

如果您只想要图像,请保存返回的结果

UIImage* img = [UIImage kitImageNamed:@"UIButtonBarLocate.png"];
于 2010-01-11T11:01:12.207 回答
1

我创建了自己的图像,Apple 接受了它(与使用搜索图像进行缩放相反)。

于 2009-08-03T13:14:02.947 回答
1

http://glyphish.com/图标库有可用的位置按钮。

于 2010-01-11T10:51:49.143 回答
0
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];

使用此代码示例将其保存为可以在项目中使用的文件!

希望这有帮助。

于 2010-03-26T12:27:19.737 回答
0

我不太确定这是系统映像。Apple 应用程序中的许多图像/按钮仅特定于该应用程序,而这个看起来就是这样。

于 2009-06-04T02:39:35.530 回答