ContentInset for MKMapView

UIScrollViewIt has an excellent property contentInsetthat tells the mind which part is visible on the screen. I have MKMapViewone that is partially covered with a translucent look. I want the map to be visible under the guise. I need to display several annotations on the map, and I want to enlarge them using -setRegion:animated:, but the map view does not take into account that it is partially covered, so some of my annotations will be covered with a translucent view.

enter image description here

Is there any way to tell the map to calculate, as shown in the scroll using contentInset?


UPDATE: This is what I tried:

- (MKMapRect)mapRectForAnnotations
{
    if (self.trafik) {
        MKMapPoint point = MKMapPointForCoordinate(self.trafik.coordinate);
        MKMapPoint deltaPoint;

        if (self.map.userLocation &&
            self.map.userLocation.coordinate.longitude != 0) {
            MKCoordinateSpan delta = MKCoordinateSpanMake(fabsf(self.trafik.coordinate.latitude-self.map.userLocation.coordinate.latitude),
                                                          fabsf(self.trafik.coordinate.longitude-self.map.userLocation.coordinate.longitude));
            deltaPoint = MKMapPointForCoordinate(CLLocationCoordinate2DMake(delta.latitudeDelta, delta.longitudeDelta));
        } else {
            deltaPoint = MKMapPointForCoordinate(CLLocationCoordinate2DMake(0.01, 0.01));
        }

        return MKMapRectMake(point.x, point.y, deltaPoint.x, deltaPoint.y);
    } else {
        return MKMapRectNull;
    }
}
+4
source share
1 answer

, UIViewController, bottomLayoutGuide. , .

bottomLayoutGuide UIViewController, MyLayoutGuide, :

@interface MyLayoutGuide : NSObject <UILayoutSupport>
@property (nonatomic) CGFloat length;
-(id)initWithLength:(CGFloat)length;
@end

@implementation MyLayoutGuide
@synthesize length = _length;
@synthesize topAnchor = _topAnchor;
@synthesize bottomAnchor = _bottomAnchor;
@synthesize heightAnchor = _heightAnchor;

- (id)initWithLength:(CGFloat)length
{
    if (self = [super init]) {
        _length = length;
    }
    return self;
}

@end

bottomLayoutGuide, MKMapView 50:

- (id)bottomLayoutGuide
{
    CGFloat bottomLayoutGuideLength = 50.f;

    return [[MyLayoutGuide alloc] initWithLength:bottomLayoutGuideLength];
}

"", setNeedsLayout MKMapView, . MKMapView, UIViewController:

- (void)updateBottomLayoutGuides
{
    // this method ends up calling -(id)bottomLayoutGuide on its UIViewController
    // and thus updating where the Legal link on the map should be.
    [self.mapView setNeedsLayout];
}

.

+3

All Articles