我正在尝试使用叠加(MKOverlay)跟踪MKMapView上的路线.但是,根据当前的速度,如果颜色正在变化(例如,如果用户从65mph驱动到30mph),我想要在跟踪路线时使用渐变来执行类似Nike应用程序的操作(例如,从绿色变为橙色).
这是我想要的截图:

因此,每隔20米,我使用以下方法添加从旧坐标到新坐标的叠加:
// Create a c array of points.
MKMapPoint *pointsArray = malloc(sizeof(CLLocationCoordinate2D) * 2);
// Create 2 points.
MKMapPoint startPoint = MKMapPointForCoordinate(CLLocationCoordinate2DMake(oldLatitude, oldLongitude));
MKMapPoint endPoint = MKMapPointForCoordinate(CLLocationCoordinate2DMake(newLatitude, newLongitude));
// Fill the array.
pointsArray[0] = startPoint;
pointsArray[1] = endPoint;
// Erase polyline and polyline view if not nil.
if (self.routeLine != nil)
self.routeLine = nil;
if (self.routeLineView != nil)
self.routeLineView = nil;
// Create the polyline based on the array of points.
self.routeLine = [MKPolyline polylineWithPoints:pointsArray count:2];
// Add …Run Code Online (Sandbox Code Playgroud) 我发现Instagram有一个300*300的相机窗口?它是一个正方形,然后我试图用GPUImage制作相同的相机尺寸.所以我这样写:
primaryView = [GPUImageView alloc] initWithFrame:
CGRectMake(0,0,300,300)];//define a square view
//define a still camera
stillCamera = [[GPUImageStillCamera alloc]
initWithSessionPreset:AVCaptureSessionPreset640x480
cameraPosition:AVCaptureDevicePositionFront];
//make it portrait
stillCamera.outputImageOrientation = UIInterfaceOrientationPortrait;
//define a filter
filter = [[GPUImageFilter alloc] init];
//force the output to 300*300
[filter forceProcessingAtSize:((GPUImageView*)self.primaryView).sizeInPixels];
//set things up
[stillCamera addTarget: filter];
[filter addTarget: primaryView];
[stillCamera startCameraCapture];
Run Code Online (Sandbox Code Playgroud)
现在我真的得到一个方形视图..但是视图看起来很平坦,它完全失真,我认为它可能是宽高比有问题.然后我设置主视图的填充模式,如下所示:
[primaryView setFillMode:kGPUImageFillModePreserveAspectRatioAndFill];
Run Code Online (Sandbox Code Playgroud)
这个:
[primaryView setFillMode:kGPUImageFillModePreserveAspectRatio];
Run Code Online (Sandbox Code Playgroud)
这个:
[primaryView kGPUImageFillModeStretch];
Run Code Online (Sandbox Code Playgroud)
最后!没有这些工作..所以我缺少什么,任何一个,帮助.