2012-07-07 17 views
5
[[[globalSingleton paintingView] drawingView] setOpaque:NO]; 
[[[[globalSingleton paintingView] drawingView] layer] setOpaque:NO];  
[[[globalSingleton paintingView] drawingView] setBackgroundColor:[UIColor clearColor]]; 
[[[[globalSingleton paintingView] drawingView] layer] setBackgroundColor:[UIColor clearColor].CGColor]; 

[[[[globalSingleton paintingView] drawingView] layer] renderInContext:ctx]; 

UIImage *image1 = UIGraphicsGetImageFromCurrentImageContext(); 

उपरोक्त कोड वह है जो मैं अपने 'ड्राइंग व्यू' को एक पीएनजी फ़ाइल में सहेजने के लिए उपयोग कर रहा हूं। मुझे कई प्रश्न और उत्तर मिले, इसलिए मैंने उन्हें लागू किया। मैंने अपने 'ड्राइंग व्यू' का अपारदर्शी और ड्राइंग व्यू.लेयर को नो के रूप में सेट किया है, और मेरे 'ड्राइंग व्यू' के पृष्ठभूमि रंग को [यूआईसीओलर क्लियरकॉलर] के रूप में सेट किया है। मुझे लगता है कि मैंने स्टैक ओवरफ्लो से सभी उत्तरों को लागू किया है। हालांकि, कुछ भी नहीं बदला है। पीएनजी फाइल की पृष्ठभूमि अभी भी काला है। मुझे पारदर्शी पृष्ठभूमि की जरूरत है, काले नहीं!UIView को पारदर्शी पृष्ठभूमि के साथ पीएनजी फ़ाइल के रूप में सहेजें

मैंने कोशिश की कि क्या UIImage * image1 के साथ कोई समस्या है या नहीं। मैंने स्क्रीन पर दिखाने के लिए image1 का उपयोग किया, फिर मुझे उस छवि 1 से काली पृष्ठभूमि मिल सकती थी। तो मुझे लगता है कि image1 बनाते समय कोई समस्या है।

यह सब मुझे मिला है। पारदर्शी पृष्ठभूमि छवि के साथ मेरी पीएनजी छवि को सहेजने के लिए कोई संभावित समाधान है? अग्रिम में धन्यवाद!!

उत्तर

8

ओह, भगवान! मैंने यह किया!! मैंने जोड़ा [[यूआईसीओलर स्पष्ट रंग] सेट]; । बस इतना ही।

UIGraphicsBeginImageContextWithOptions(screenRect.size, NO, [[UIScreen mainScreen] scale]); 

CGContextRef ctx = UIGraphicsGetCurrentContext(); 
[[UIColor clearColor] set]; 
CGContextFillRect(ctx, screenRect); 

[[[globalSingleton paintingView] drawingView] setOpaque:NO]; 
[[[[globalSingleton paintingView] drawingView] layer] setOpaque:NO];  
[[[globalSingleton paintingView] drawingView] setBackgroundColor:[UIColor clearColor]]; 
[[[[globalSingleton paintingView] drawingView] layer] setBackgroundColor:[UIColor clearColor].CGColor]; 

[[[[globalSingleton paintingView] drawingView] layer] renderInContext:ctx]; 

UIImage *image1 = UIGraphicsGetImageFromCurrentImageContext(); 
संबंधित मुद्दे