मैं पूरे स्क्रीन, screenshot
का एक स्क्रीनशॉट है, उत्पन्न का उपयोग कर निम्न:स्विफ्ट: फसल एक स्क्रीनशॉट
let layer = UIApplication.sharedApplication().keyWindow!.layer
let scale = UIScreen.mainScreen().scale
UIGraphicsBeginImageContextWithOptions(layer.frame.size, false, scale);
layer.renderInContext(UIGraphicsGetCurrentContext())
let screenshot = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
ताकि टैब बार शामिल नहीं है मैं इसे काटने के लिए चाहते हैं, और मैंने कोशिश की
let crop = CGRectMake(0, 0, //"start" at the upper-left corner
self.view.bounds.width, //include half the width of the whole screen
self.view.bounds.height + self.navigationController!.navigationBar.frame.height) //include the height of the navigationBar and the height of view
let cgImage = CGImageCreateWithImageInRect(screenshot.CGImage, crop)
let image: UIImage = UIImage(CGImage: cgImage)!
सही से भी कम समय के लिए इस कोड को image
में परिणाम स्क्रीन के केवल एक छोटा सा हिस्सा दिखा रहा है, एक आयत स्क्रीन के ऊपरी-बाएं कोने पर शुरू (0, 0), और विस्तार: निम्नलिखित कोड का उपयोग कर स्क्रीन की आधा चौड़ाई, फिर हेक्टेयर से कम के लिए नीचे की ओर स्क्रीन की ऊंचाई एलएफ। हालांकि, टैब टैब द्वारा कब्जे वाले क्षेत्र को छोड़कर, मुझे संपूर्ण स्क्रीन शामिल करना होगा। क्या इसे फसल करने का कोई तरीका है?
पूरी तरह से काम करता है-धन्यवाद; बक्षीस आना है। – Randoms
आपका स्वागत है :) – sahara108