0

我的视图控制器中有一个地图视图。它显示预先输入的坐标的视图。地图视图不占据整个屏幕,我在视图控制器上还有其他项目。我想编辑地图视图的外观,使边缘弯曲而不是矩形地图视图。

我的视图 controller.m 代码:

#import "ViewController.h"
#import <MapKit/MapKit.h>
#import <QuartzCore/QuartzCore.h>
@interface ViewController ()

@end
@implementation ViewController



@synthesize topLayer = _topLayer;
@synthesize layerPosition = _layerPosition;
@synthesize mapView;
- (void)viewDidLoad
{
[super viewDidLoad];


[self gotolocation];



self.topLayer.layer.shadowOffset = CGSizeMake(-1,0);
self.topLayer.layer.shadowOpacity = .9;




self.layerPosition = self.topLayer.frame.origin.x;

}

#define VIEW_HIDDEN 264

-(void) animateLayerToPoint:(CGFloat)x
{
[UIView animateWithDuration:0.3
                      delay:0
                    options:UIViewAnimationCurveEaseOut
                 animations:^{
                     CGRect frame = self.topLayer.frame;
                     frame.origin.x = x;
                     self.topLayer.frame = frame;
                 }
                 completion:^(BOOL finished){
                     self.layerPosition =self.topLayer.frame.origin.x;

                 }];
}

- (IBAction)toggleLayer:(id)sender {


    if (self.layerPosition == VIEW_HIDDEN) {
        [self animateLayerToPoint:0];
    } else {
        [self animateLayerToPoint:VIEW_HIDDEN];
    }



}

- (IBAction)panLayer:(UIPanGestureRecognizer*)pan {
if (pan.state == UIGestureRecognizerStateChanged) {
    CGPoint point  = [pan translationInView:self.topLayer];
    CGRect frame = self.topLayer.frame;
    frame.origin.x = self.layerPosition + point.x;
    if (frame.origin.x < 0 ) frame.origin.x = 0;
    self.topLayer.frame = frame;
}
if (pan.state == UIGestureRecognizerStateEnded) {
    if (self.topLayer.frame.origin.x <= 160) {
        [self animateLayerToPoint:0];
    } else {
        [self animateLayerToPoint: VIEW_HIDDEN];
    }
}
}

- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}



-(void) gotolocation {


MKCoordinateRegion newRegion;
newRegion.center.latitude = 28.533569;
newRegion.center.longitude = 77.144776;
newRegion.span.latitudeDelta = 0.001657;
newRegion.span.longitudeDelta = 0.00284;



CLLocationCoordinate2D coordinate;
coordinate.latitude = 28.533569; coordinate.longitude = 77.144776;

 MKPointAnnotation *annotation = [[MKPointAnnotation alloc] init];
[annotation setCoordinate:coordinate];
[annotation setTitle:@"Vasant Valley School"];

[self.mapView addAnnotation:annotation];

  [self.mapView setRegion:newRegion animated:YES];





    }



@end
4

1 回答 1

0
[self.mapView.layer setCornerRadius:50];
[self.mapView.layer setMasksToBounds:YES];

并导入

#import <QuartzCore/QuartzCore.h>
于 2013-06-18T09:40:42.583 回答