gpt4 book ai didi

iOS 如何以编程方式绘制具有不确定半径的 "blue dot",如 iOS7 map 应用程序?

转载 作者:行者123 更新时间:2023-11-29 10:41:46 24 4
gpt4 key购买 nike

我正在尝试创建一个看起来类似于 map 应用程序中的“蓝点”的 View 。添加中心点很容易,但我感兴趣的是如何在蓝点周围添加一个带有内/外发光的“不确定”半径?

enter image description here

 if(self.blueDot == nil)
{
self.blueDot = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,30,30)];
self.blueDot.backgroundColor = [UIColor blueColor];
self.blueDot.layer.cornerRadius = self.blueDot.bounds.size.width/2.0;

self.blueDot.layer.borderColor =[UIColor whiteColor].CGColor;
self.blueDot.layer.borderWidth = 4;
self.blueDot.userInteractionEnabled = NO;
}


if(self.blueDot.superview == nil)
{
[self.mapImitationView addSubview:self.blueDot];
}

最佳答案

我已经在一些可能有用的开源代码中完成了此操作。但首先,你的问题并不清楚你在谈论哪个元素。有:

  1. 用户位置点(我称之为 userLocation)。图像中的蓝点和白点。

  2. GPS 精度指标(我称之为accuracyCircleAnnotation)。你的形象中没有这个。

  3. 脉冲指示器,一旦准确度高到足以帮助突出显示用户时就会显示(我称之为 trackingHaloAnnotation)。这是您图像中的蓝白光晕,但该图像来自 iOS 6 及更早版本。

您可以在 RMMapView 类中看到所有这些,并带有动画,特别是这里:

这里需要注意的是,由于内置的​​框架,它是通过 CALayer 完成的,而不是直接通过 UIView 完成的。

您可以在此处找到 Apple 使用的资源,这些资源是使用 iOS-Artwork-Extractor 从 MapKit 中提取的:

https://github.com/mapbox/mapbox-ios-sdk/tree/release/MapView/Map/Resources

希望这对您有所帮助。

关于iOS 如何以编程方式绘制具有不确定半径的 "blue dot",如 iOS7 map 应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24208197/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com