我正在使用answer os this post更改屏幕上的地图法律文本位置(将其放在屏幕的右上角)。它工作得很好,但当地图旋转时,它就失败了。
我尝试在下面的方法中插入代码,以获得旋转的结束:
- (void)mapView:(MKMapView *)mapView didChangeUserTrackingMode:(MKUserTrackingMode)mode animated:(BOOL)animated但法律文本返回到其原始位置(左下角)。
如何在轮换结束后再次移动法律文本?
发布于 2014-07-08 21:09:23
在viewDidAppear中添加以下内容以更改合法标签位置
UILabel *attributionLabel = [mapView.subviews objectAtIndex:1]; attributionLabel.center = CGPointMake(attributionLabel.center.x, attributionLabel.center.y - 44.0f);
或者使用topLayoutGuide和bottomLayoutGuide的另一种解决方案
.h
@interface MapLayoutGuide : NSObject <UILayoutSupport> @property (nonatomic) CGFloat aaLength; - (id)initWithLength:(CGFloat)length; @end
.m
@implementation MapLayoutGuide - (id)initWithLength:(CGFloat)length { self = [super init]; if (self) { _aaLength = length; } return self; } - (CGFloat)length { return _aaLength; } @end
用法:
- (id<UILayoutSupport>)topLayoutGuide { return [[MapLayoutGuide alloc]initWithLength:44]; } - (id<UILayoutSupport>)bottomLayoutGuide { return [[MapLayoutGuide alloc]initWithLength:44]; }
https://stackoverflow.com/questions/22470101
复制相似问题