- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我创建图钉图像的代码如下:
MKMapSnapshotOptions *options = [[MKMapSnapshotOptions alloc] init];
options.region = MKCoordinateRegionMakeWithDistance(userLocation, 300, 300) ;
options.size = CGSizeMake(320,180);
options.scale = [UIScreen mainScreen].scale;
MKMapSnapshotter *snapShotter = [[MKMapSnapshotter alloc] initWithOptions:options];
[snapShotter startWithCompletionHandler:^(MKMapSnapshot *snapshot, NSError *error) {
//
if (error) {
NSLog(@"err = %@",[error description]);
}
UIImage *img = snapshot.image;
MKAnnotationView *pin = [[MKPinAnnotationView alloc] initWithAnnotation:nil reuseIdentifier:nil];
CGPoint coordinatePoint = [snapshot pointForCoordinate:userLocation];
coordinatePoint.x += pin.centerOffset.x - (CGRectGetWidth(pin.bounds) / 2.0);
coordinatePoint.y += pin.centerOffset.y - (CGRectGetHeight(pin.bounds) / 2.0);
UIGraphicsBeginImageContextWithOptions(img.size, YES, img.scale);
{
[img drawAtPoint:CGPointZero];
[pin.image drawAtPoint:coordinatePoint];
_imgViewMapThubbnail.image = UIGraphicsGetImageFromCurrentImageContext();
}
UIGraphicsEndImageContext();
_imgViewMapThubbnail.layer.cornerRadius = 10 ;
_imgViewMapThubbnail.layer.masksToBounds = true ;
}];
此代码是正常的红色引脚,位置几乎正确。我想要我的自定义 pin,所以我添加了如下代码
pin.image = [UIImage imageNamed:@"MY_IMAGE_NAME"];
Pin 图像已更改,并且可以正常工作。但是,我的位置有些不同。我不知道,如何调整我的代码或固定图像大小以将其设置到正确的位置?
最佳答案
看到这是一个老问题,对于任何来这里自定义图钉图像的人来说,这里是上述示例的修订代码,可以将图钉呈现在正确的位置。
CGPoint coordinatePoint = [snapshot pointForCoordinate:newCenter];
UIImage *pin = [UIImage imageNamed:@"pin"];
CGPoint centerOffset = CGPointMake(0, -pin.size.height / 2);
coordinatePoint.x += centerOffset.x - (pin.size.width / 2.0);
coordinatePoint.y += centerOffset.y - (pin.size.height / 2.0);
UIGraphicsBeginImageContextWithOptions(img.size, YES, img.scale);
{
[img drawAtPoint:CGPointZero];
[pin drawAtPoint:coordinatePoint];
_imgViewMapThubbnail.image = UIGraphicsGetImageFromCurrentImageContext();
}
UIGraphicsEndImageContext();
关于ios - MKMapSnapshotter 如何设置pin Image,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33755097/
我正在使用 - (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id ) annotation{ 为自定义图钉
试图了解Box::pin()和Pin::new_unchecked()之间的区别。假设以下代码: use std::pin::Pin; use std::marker::PhantomPinned;
我有最新版本的 Intel Pin 3.0 版本 76887。 我有一个支持 MPX 的玩具示例: #include int g[10]; int main(int argc, char **arg
我正在寻找一种算法来创建类似于预付费电话卡的安全唯一随机数。我确实看过Generating a unique 15 digite Pin code from a 10digit number但它确实让
作为Hans Passant wishes这是我的场景。我有一个混合模式应用程序,其中 native 代码完成所有艰苦的工作,同时尊重性能,托管代码仅负责 GUI。用户也将通过编写他们专有的 C# 代
我正在尝试解决一个我不确定如何解决的问题。在我的应用程序中,本地图套件启动时,我会在用户的当前位置放置一个图钉。 Mapkit 委托(delegate)给 viewForAnnotation,它设置了
我在 android 应用程序中集成了 admob,我达到了阈值。它会显示一条消息,您的付款目前处于暂停状态,因为您尚未验证您的地址 有什么方法可以避免等待数周才能从 admob 收到用于地址验证的
我正在使用 get_user_pages在 Linux 内核驱动程序中,为了 [硬件] DMA 固定内存。一切似乎都很好 - 但我很难证明“固定”正在做正确的事情。 当我在做 get_user_pag
在使用 MKMapView 时,我确实注意到了 IOS 11 上的一个问题。 当我想从图钉对话框中点击按钮 Action 并且按钮 Action 后面有另一个图钉时,它没有得到手势。 应该是zPosi
我是 PIN 工具的新手。我只是尝试运行自述文件中给出的示例代码。 最初我使用以下方式构建: $ cd source/tools/ManualExamples $ make all 它正确编译并创建了
我遇到一个小问题...我有自己的网站,带有一个简单的 mysqli 登录脚本,每当我输入用户名、密码和 PIN 码时,它都会让我登录... 我现在的问题是,我可以仅使用用户名和密码登录我的网站(无需输
我有一个显示现金点位置的 map View 。注释被删除,可以单击标注以转到包含有关该位置的更多详细信息的页面。提款机分为免费和付费两种,免费的提款机别针是绿色的,另一个是红色的。当别针掉落时,它们就
我正在构建一个带有 GSM 调制解调器和 SIM 卡的设备。我想用别针保护 SIM 卡,以防止在现场安装设备时误用。 将关联 SIM 卡的 PIN 码存储到每个设备中会很麻烦。此外,如果更换 SIM
我正在编写一个需要共享流所有权的流适配器。 将流(私下)存储在 Pin>> 中是否正确? ? 如何调用poll_next(self: Pin在流? 最佳答案 Mutex没有所谓的结构钉扎,这在 std
我对 Pin 的要求感到困惑那个 a value, once pinned, must remain pinned forever. 我看到了the discussion thread on redd
我目前正在实现 TrustKit framework在我的 iOS 应用程序中为 SSL 连接启用 SPKI 固定。我偶然发现了正确配置 TrustKit 所必需的“备用密码”。不幸的是,API 文档
在 rust 中学习 Pin 的实现时我很困惑。 我知道当一个类型不能安全移动时,它可以实现 !Unpin。 Pin 是为了防止别人从这些类型中获取到&mut T,使他们不能是std::mem::sw
我用的是 SIM868 模块,我用的是我常用的 SIM 卡,没有问题,但现在我买了一张新的 SIM 卡,没有 pin。我需要添加 PIN 码以提高安全性。 我使用以下命令检查了它是否没有启用 PIN:
我想知道是否可以在自定义 MKMapView 中创建 MKPinAnnotation,它可以像 map 应用程序中的“Drop Pin”注释一样响应触摸和拖动。 我想要一种在 GPS 给出的位置放置图
我正在开发一个应用程序,我需要通过为用户设置密码/密码/密码来设置安全功能,以便每当他们从后台打开应用程序时,应用程序都会要求输入密码/密码/密码。我阅读了一些文章/解决方案,例如 this但他们没有
我是一名优秀的程序员,十分优秀!