gpt4 book ai didi

iphone - 黑色半透明导航栏 + MKMapView -> 设置 map 中心在视觉上不正确

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:45:49 24 4
gpt4 key购买 nike

我在半透明的黑色导航、状态和搜索以及工具栏下的导航 Controller 中有一个 map View 。

map 的实际高度包括这些条形下方的区域。

+ 左侧附件按钮使 map 在 Pin 图上居中。

Photo1 Photo2

左图是 map 以图钉坐标为中心之前的图像。

右边是 map 以大头针坐标为中心的情况。

问题是中心应该是可见 map 区域的中心,而不是整个 map 区域的中心。 (这会导致图钉不会出现在 map 的中心。

是否可以设置一些偏移量或边界设置以使 map View 正确居中?

最佳答案

您可以为您的可见 map 区域(在导航栏下方)覆盖一个透明的 UIView (tView),了解他的观点,计算您需要的偏移量并再次设置区域。 (我猜你正在使用 setRegion 使 map 居中):

CGPoint currentPoint = [mapView convertCoordinate:myPin.coordinate toPointToView:self.view];
CGRect tFrame = [tView frame];
tFrame.origin.y = currentPoint.y - tFrame.size.height;
tFrame.origin.x = currentPoint.x - (tFrame.size.width/2);

MKCoordinateRegion newRegion = [mapView convertRect:tFrame toRegionFromView:self.view];
[mapView setRegion:newRegion animated:YES];

您应该仔细检查 tFrame,以便为您的应用设置最佳值。

关于iphone - 黑色半透明导航栏 + MKMapView -> 设置 map 中心在视觉上不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9514808/

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