如何根据距离点的距离创建缩放效果

时间:2012-02-17 07:28:00

标签: iphone ios xcode

我正在制作一个增强现实项目,并希望在图像中创建缩放效果:我希望在距离缩小时该图像可以放大。

  1. 我已经有距离了。
  2. 我有图像。
  3. 我有缩放开始的最大距离。

1 个答案:

答案 0 :(得分:0)

以下代码用于缩放par作为引脚的距离。

-(void) centerMap 

{
    MKCoordinateRegion region;
    CLLocationDegrees maxLat = -90;
    CLLocationDegrees maxLon = -180;
    CLLocationDegrees minLat = 120;
    CLLocationDegrees minLon = 150;
    NSArray *temp=self.AS;
//  NSArray *temp=[NSArray arrayWithArray:[NSArray arrayWithArray:[reports objectAtIndex:0]]];
    for (int i=0; i<[temp count];i++) {
        Place* home = [[[Place alloc] init] autorelease];
        home.latitude = [[[temp objectAtIndex:i] valueForKey:@"latitude"]floatValue];
        home.longitude =[[[temp objectAtIndex:i] valueForKey:@"longitude"]floatValue];

        PlaceMark* from = [[[PlaceMark alloc] initWithPlace:home] autorelease];     

        CLLocation* currentLocation = (CLLocation*)from ;
        if(currentLocation.coordinate.latitude > maxLat)
            maxLat = currentLocation.coordinate.latitude;
        if(currentLocation.coordinate.latitude < minLat)
            minLat = currentLocation.coordinate.latitude;
        if(currentLocation.coordinate.longitude > maxLon)
            maxLon = currentLocation.coordinate.longitude;
        if(currentLocation.coordinate.longitude < minLon)
            minLon = currentLocation.coordinate.longitude;

        region.center.latitude     = (maxLat + minLat) / 2;
        region.center.longitude    = (maxLon + minLon) / 2;
        region.span.latitudeDelta  =  maxLat - minLat;
        region.span.longitudeDelta = maxLon - minLon;
    }
    [mapView setRegion:region animated:YES];

}

- (MKAnnotationView *)mapView:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>)annotation
{

    if (annotation == mapView.userLocation) 
        return nil;

    MKPinAnnotationView *pin = (MKPinAnnotationView *) [mapView dequeueReusableAnnotationViewWithIdentifier: @"asdf"];

    if (pin == nil)
        pin = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier: @"asdf"] autorelease];
    else
        pin.annotation = annotation;
    pin.userInteractionEnabled = YES;
    UIButton *disclosureButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; 
    [disclosureButton setFrame:CGRectMake(0, 0, 30, 30)];

    pin.rightCalloutAccessoryView = disclosureButton;
    pin.pinColor = MKPinAnnotationColorRed;
    //pin.animatesDrop = YES;
    [pin setEnabled:YES];
    [pin setCanShowCallout:YES];
    return pin;

}

此代码可能有助于创建新的应用程序,