1
繪製尺寸調整的圖像我有兩個ImageViews,一個叫ImageView的和其他的稱爲子視圖(其是ImageView的的子視圖)。混合兩個圖像和從兩個的UIImageViews
我想在這些視圖混合的圖像一起,與用戶能夠切換所述共混物的α與鍋。我的代碼工作,但現在,該代碼是緩慢的,因爲我們每個移動手勢移動時重繪圖像。有沒有更快/更有效的方式來做到這一點?
紅利問:我想允許我的subView圖像繪製放大。目前我已經設置我的子視圖爲UIViewContentModeCenter,但我似乎無法使用此內容模式繪製縮放圖像的一部分。有沒有辦法解決?
我的drawRect:
- (void)drawRect:(CGRect)rect
{
float xCenter = self.center.x - self.currentImage1.size.width/2.0;
float yCenter = self.center.y - self.currentImage1.size.height/2.0;
subView.alpha = self.blendAmount; // Customize the opacity of the top image.
UIGraphicsBeginImageContext(self.currentImage1.size);
CGContextRef c = UIGraphicsGetCurrentContext();
CGContextSetBlendMode(c, kCGBlendModeColorBurn);
[imageView.layer renderInContext:c];
self.blendedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[self.blendedImage drawAtPoint:CGPointMake(xCenter,yCenter)];
}
謝謝 - 我已經嘗試切換到使用核心繪圖但現在看來,就像我在我的drawRect來達到同樣的效果應用兩個過濾器:CIColorMatrix(調整頂部圖像的阿爾法),然後CIBlendFilter(以添加混合)。這使得整個過程緩慢(如果不是比以前慢!)。你知道有沒有辦法解決這個問題? – HHHH
設法讓這一輪。謝謝你的提示! – HHHH