how to draw line between two points?

前端 未结 6 562
难免孤独
难免孤独 2021-01-03 14:43

i want to draw line between two points in my view how it possible.?

Edit:ya thax.i have got solution. Line draw perfectly.I want to draw multiple line with different

6条回答
  •  南方客
    南方客 (楼主)
    2021-01-03 15:18

    #pragma mark - Mapview Delegate Method
    - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id )annotation
    {
        MKPinAnnotationView *pin = (MKPinAnnotationView *) [self.mapView dequeueReusableAnnotationViewWithIdentifier: @"id"];
    
        if (!pin && ![annotation isKindOfClass:[MKUserLocation class]])
        {
    
            pin = [[MKPinAnnotationView alloc] initWithAnnotation: annotation reuseIdentifier: @"id"] ;
            pin.pinTintColor=[UIColor blueColor];
            pin.canShowCallout = true;
        }
        else
        {
    
            if (pin == nil)
            {
                pin = [[MKPinAnnotationView alloc] initWithAnnotation: annotation reuseIdentifier: @"id"] ;
            }
            else
            {
                pin.annotation = annotation;
            }
    
            pin.pinTintColor=[UIColor grayColor];
    
            UIView *notationView=[[UIView alloc]init];
            notationView.frame=CGRectMake(0, 0,  320, 300);
            notationView.backgroundColor = [UIColor grayColor];
    
            UILabel *lbl=[[UILabel alloc]init];
            lbl.frame=CGRectMake(5, 5, 300, 25);
            lbl.text=@"Current Location";
            lbl.textColor=[UIColor whiteColor];
            [notationView addSubview:lbl];
    
            UIImageView *img=[[UIImageView alloc]init];
            img.frame=CGRectMake(0, 0, 50,50);
    
            img.image=[UIImage imageNamed:@"ios.png"];
    
           //  pin.leftCalloutAccessoryView = notationView;
           // pin.rightCalloutAccessoryView = img;
    
            //pin.detailCalloutAccessoryView=customView;
    
             pin.animatesDrop = true;
    
            pin.canShowCallout = true;
    
        }
    
      return pin;
    }
    

提交回复
热议问题