1
我想掩蓋的圖像像這樣的代碼:如何使用uiimageview rect遮罩圖像?
CGFloat plx = inputImage.size.width/_imageView.frame.size.width;
CGFloat ply = inputImage.size.height/_imageView.frame.size.height;
CGFloat radius = MIN(_postionView.frame.size.width * plx, _postionView.frame.size.height * ply)/1.5;
CIVector *cen = [CIVector vectorWithX:_postionView.center.x * plx Y:_postionView.center.y * ply];
CIFilter *radialGradient = [CIFilter filterWithName:@"CIRadialGradient" keysAndValues:
@"inputRadius0", [NSNumber numberWithFloat:radius],
@"inputRadius1", [NSNumber numberWithFloat:radius + 1.0f],
@"inputColor0", [CIColor colorWithRed:0.0 green:1.0 blue:0.0 alpha:1.0],
@"inputColor1", [CIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0],
@"inputCenter", cen,
nil];
CIImage *circleImage = [radialGradient valueForKey:kCIOutputImageKey];
_postionView是我的UIImageView。它沒有得到正確的位置。我猜這是因爲uikit座標系和石英不同的座標系。有任何想法嗎?