दीमा ने जो जवाब दिया, उसका निर्माण मैंने सोचा कि लोगों को शुरू करने के लिए कुछ बुनियादी कार्यान्वयन मदद कर सकता है। चूंकि दीमा ने कहा कि यह स्टेटस बार नहीं ले जा रहा है, यह स्टेटस बार की एक छवि को ले जा रहा है।
अस्वीकरण: तो मैं
UIView *screen = [[UIScreen mainScreen] snapshotViewAfterScreenUpdates:NO];
तो का उपयोग कर कोई गारंटी अगर यह बॉक्स
iOS7 के साथ शुरू से बाहर काम करेंगे पर आप एक तस्वीर ले जा सकते हैं बनाने के मैं इस कार्यान्वयन YOLO'd मूल रूप से स्टेटस बार को चित्र से फसल किया जाता है और में windowLevel
UIWindowStatusLevelBar
से ऊपर जोड़ा गया है ताकि आप इसे वास्तविक स्थिति पट्टी पर देख सकें। कुछ की तरह:
UIWindow *statusBarWindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
statusBarWindow.windowLevel = UIWindowLevelStatusBar + 1; // higher
statusBarWindow.hidden = NO; // fun fact you don't have to add a UIWindow to anything, just setting hidden = NO should display it
statusBarWindow.backgroundColor = [UIColor clearColor]; // since visible, make it clear until we actually add the screen shot to it so as to not block anything
...
// The view that will hold the screen shot
// Later, I think we're going to need to play with contentInsets to make the view look like its staying still, so we're making it a UIScrollView in case
UIScrollView *statusBarView = [[UIScrollView alloc] initWithFrame:[UIApplication sharedApplication].statusBarFrame];
statusBarView.clipsToBounds = YES;
// Now we add the screen shot we took to this status bar view
[scrollingStatusBarView addSubview:statusBarView];
[statusBarView addSubview:screen]; // screen is the UIScrollView from previous code block (the screen shot)
// Now add this statusBarView with the image to the window we created
[statusBarWindow addSubview:statusBarView];
अब बाकी वास्तव में क्या अपने कार्यान्वयन की तरह लग रही है, लेकिन यहां से आप वास्तव में सिर्फ या तो एक पैन के साथ दृश्य चलती संभालने की ज़रूरत है पर निर्भर करता है, या जो कुछ भी कार्रवाई नए दृश्य में आने के लिए खड़ी कर रहा है पक्ष के माध्यम से।
[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:NO];
// anything else you might feel like doing
अब हम कुछ दिलचस्प यहाँ पर जा रहा है:
जब शुरू होता है स्वाइप, जो कुछ भी शैली, पृष्ठभूमि के साथ अपने नए स्थिति पट्टी (एक नीचे), जो कुछ भी कॉन्फ़िगर करें। जैसे-जैसे संक्रमण चलता है, आपको statusBarView
की ऑफ़सेट राशि बंद करने के लिए स्क्रॉल की गई राशि को "स्निप" करने के लिए उपयोग करना होगा। statusBarView.frame
को x = ऑफसेट पर शुरू करना होगा या अन्यथा यह वास्तविक स्थिति पट्टी पर दिखाएगा (क्योंकि यह विंडो अधिक है), लेकिन यदि आप सामग्री इन्सटेट्स नहीं बदलते हैं तो तस्वीर संक्रमण के साथ स्लाइड हो जाएगी। तो भ्रम पैदा करने के लिए आपको उसी राशि से बाएं सामग्री इन्सेट को बढ़ाने के दौरान मूल को दाईं ओर धक्का देना होगा, इसलिए यह उसी स्थान पर दिखाई देता है।
तो जो कुछ भी विधि रपट कार्रवाई से निपटने है अंदर:
नोट: यह व्यक्तिगत कार्यान्वयन पर निर्भर दृढ़ता से होगा और शायद कुछ प्रयोग
// if you're using an animation to handle the transition you can match up this change in x position with the animation
// if you're doing via pan gesture you could try something like:
CGFloat offset = self.viewThatIsScrolling.contentOffset.x; // may be negative depending on direction that is being swiped
if (midTransition) { // you can use the offset value here to check
// NOTE: again, will depend on which direction this animation is happening in. I'll assume a new view coming in from left (so swiping right)
statusBarView.frame = CGRectMake(offset, 0, self.statusBarView.frame.width, 20.0f); // move the origin over to the right
statusBarView.contentInsets = UIEdgeInsetsMake(0, offset, 0, 0); // make the picture start 'offset' pixels to the left so it'll look like it hasn't moved
}
(साइड नोट ले जाएगा: आप भी कर सकते हैं फ्रेम को स्पष्ट रूप से सेट करने के बजाय एक परिवर्तन का उपयोग करने का प्रयास करें: statusBarView.transform = CGAffineTransformMakeTranslation(offset -previousOffsetAmount, 0);
। मैं पिछले ऑफसेट एमाउंट का उपयोग करता हूं क्योंकि आप केवल इसे जो भी नई राशि से जोड़ सकते हैं, उससे मेल खाना चाहते हैं। इसे किसी भी तरह से ट्रैक किया जाना चाहिए यदि आप इसे जाते हैं मार्ग)
और अंत में 'रपट' किया जाता है, मत भूलना एक बार पूरी तरह से खिड़की से स्क्रीनशॉट दूर करने के लिए:
// if continuing from before:
if (midTransition) {
...
} else { // the view has been slid completely
[statusBarView removeFromSuperview];
statusBarView = nil;
// I'm keeping the UIWindow where it is for now so it doesn't have to be recreated and because it has a clear background anyways
}
// if this is being done via animation the above can be called the animation finishes
मैं वास्तव में यह काम करने के लिए प्राप्त करने की कोशिश में रुचि हो सकती, तो अगर ऐसा होगा तो अपडेट होगा।
शायद वे बार-बार स्टेटस बार को स्क्रीन-कैप कर रहे हैं और संक्रमण के दौरान उन स्क्रीन कैप्स को बार-बार संशोधित कर रहे हैं। या शायद वे बैटरी/समय/सिग्नल में परिवर्तन का पता लगा रहे हैं, फिर उन चीजों को बदलने पर केवल स्क्रीन कैपिंग। –
स्पष्ट रूप से कुछ गहरे जादू की शुरुआत है। – CrimsonChris