我在UIView上有兩個UIImageView。 每個UIImageView都有一個UIImage。現在我想從兩個UIImageView創建一個UIImage。從兩個UIImageView創建一個UIImage
請給出建議,我該如何做到這一點。
我在UIView上有兩個UIImageView。 每個UIImageView都有一個UIImage。現在我想從兩個UIImageView創建一個UIImage。從兩個UIImageView創建一個UIImage
請給出建議,我該如何做到這一點。
如果您有三個UIImageViews的一個視圖,並創建對應的出口
IBOutlet UIImageView *imageView1;
IBOutlet UIImageView *imageView2;
IBOutlet UIImageView *imageView3;
你可以做一些類似下面的imageViews 1和2組合成的ImageView 3
UIGraphicsBeginImageContext(imageView1.image.size);
CGRect rect = CGRectMake(0, 0, imageView1.image.size.width, imageView1.image.size.height);
[imageView1.image drawInRect:rect];
[imageView2.image drawInRect:rect blendMode:kCGBlendModeScreen alpha:0.5];
UIImage *resultingImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[imageView3 setImage:resultingImage];
CGBlendMode讓你選擇以下任何合成操作爲您的圖像:
enum CGBlendMode {
kCGBlendModeNormal,
kCGBlendModeMultiply,
kCGBlendModeScreen,
kCGBlendModeOverlay,
kCGBlendModeDarken,
kCGBlendModeLighten,
kCGBlendModeColorDodge,
kCGBlendModeColorBurn,
kCGBlendModeSoftLight,
kCGBlendModeHardLight,
kCGBlendModeDifference,
kCGBlendModeExclusion,
kCGBlendModeHue,
kCGBlendModeSaturation,
kCGBlendModeColor,
kCGBlendModeLuminosity,
kCGBlendModeClear,
kCGBlendModeCopy,
kCGBlendModeSourceIn,
kCGBlendModeSourceOut,
kCGBlendModeSourceAtop,
kCGBlendModeDestinationOver,
kCGBlendModeDestinationIn,
kCGBlendModeDestinationOut,
kCGBlendModeDestinationAtop,
kCGBlendModeXOR,
kCGBlendModePlusDarker,
kCGBlendModePlusLighter
};
尼爾斯城堡 - 我需要執行相同的操作。我的主要imageview是靜態的,但我的第二個imageview是可拖動的。所以上面的代碼創建我的第二個imageview相同的主要imageview界限。如何將這兩個圖像合併爲一個,而不將其綁定爲mainImageview?謝謝。 – iOSAppDev 2011-11-01 16:26:18
我不確定你實際上想要實現什麼。產生的圖像疊加了2張圖像或其他圖像之一.. – Nithin 2010-01-05 10:49:26