UIImage
은 UIImageView
으로 표시됩니다. 또한 첫 번째 이미지 위에있는 UIImageView
에 다른 이미지가 있습니다. 첫 번째 이미지의 테두리 내에서만 두 번째 이미지를 드래그 할 수 있기를 원합니다. 내 목표를이 이미지를 좀더 명확하게 보려면 http://img689.imageshack.us/img689/6136/56308823.png.UIImage를 다른 UIImage 내부로 이동하십시오.
녹색 핀은 드래그 가능해야하지만 파란색 핀 (지도 외부)으로 드래그 할 수 없어야합니다. 현재 핀은 드래그 가능하지만 핀이지도 외부에 있는지 확인하는 방법을 모르겠습니다.
편집
: 나는 드래그 할 수 핀 내있는 UIImageView 하위 클래스에서이 방법을 사용 : 맵에 대한 UIIImageView이 어디- (UIColor *)colorAtPosition:(CGPoint)position {
CGRect sourceRect = CGRectMake(position.x, position.y, 1.f, 1.f);
CGImageRef imageRef = CGImageCreateWithImageInRect([[MapViewController sharedMapViewController]getImage].CGImage, sourceRect);
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
unsigned char *buffer = malloc(4);
CGBitmapInfo bitmapInfo = kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big;
CGContextRef context = CGBitmapContextCreate(buffer, 1, 1, 8, 4, colorSpace, bitmapInfo);
CGColorSpaceRelease(colorSpace);
CGContextDrawImage(context, CGRectMake(0.f, 0.f, 1.f, 1.f), imageRef);
CGImageRelease(imageRef);
CGContextRelease(context);
CGFloat r = buffer[0]/255.f;
CGFloat g = buffer[1]/255.f;
CGFloat b = buffer[2]/255.f;
CGFloat a = buffer[3]/255.f;
free(buffer);
return [UIColor colorWithRed:r green:g blue:b alpha:a];
}
MapViewController가의 ViewController입니다. 그래서이 클래스를지도 이미지를 얻기 위해 싱글 톤으로 만들었습니다. 그러나 다시 색상 값은 전적으로 유선입니다. 또한 내 ui가 약간 달라서 사진을 업데이트했습니다.
아래 답변에 대한 내 의견을보십시오. 이 문제를 해결하는 다른 방법이 있습니까? – dehlen