iPhone 位置按钮

发布于 2024-07-22 21:42:42 字数 139 浏览 9 评论 0原文

您知道地图应用程序左下角的小位置按钮吗? 有谁知道我在哪里可以找到它? 我查看了 UIButtonType 和 UITabBarSystemItem 但一无所获。

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

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

江心雾 2024-07-29 21:42:42

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

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

我模仿了 Google 地图的“定位我”按钮,包括 4 种不同的状态以及切换时完成的动画状态之间。

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.

染柒℉ 2024-07-29 21:42:42

您可以尝试使用 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];

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];
森林散布 2024-07-29 21:42:42

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

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.

西瓜 2024-07-29 21:42:42

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

位置按钮可以通过以下方式访问:

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

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

UIImage* img = [UIImage kitImageNamed:@"UIButtonBarLocate.png"];

(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"];
琴流音 2024-07-29 21:42:42

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

I created my own image, and Apple accepted it (in contrast of using the search image for zooming purposes).

单挑你×的.吻 2024-07-29 21:42:42

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

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

却一份温柔 2024-07-29 21:42:42

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

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.

鸠魁 2024-07-29 21:42:42
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];

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

希望这有帮助。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文