मेरे मुख्य दृश्य में, मैं कुछ इशारा करता हूं जिससे कुछ नया दृश्य दिखाना पड़ता है। इस समय मैं एक अच्छी यूआई अभ्यास के रूप में पूरी पृष्ठभूमि (इस नए दृश्य को छोड़कर) को मंद करना चाहता हूं। एचटीएमएल में, जावास्क्रिप्ट ऐसा लगता है - मैं आईओएस में यह वही प्रभाव कैसे प्राप्त करूं?आईओएस मंद पृष्ठभूमि जब एक दृश्य दिखाया गया है
उत्तर
पृष्ठभूमि के ऊपर एक UIView निर्धारित करना, [UIColor blackColor]
करने के लिए अपनी पृष्ठभूमि सेट और 0.6 पसंद करने के लिए अपने अस्पष्टता निर्धारित किया है। फिर उस UIView को मूल दृश्य में जोड़ें।
यह पृष्ठभूमि को मंद कर देगा और पृष्ठभूमि नियंत्रण में किसी भी नल को रोक देगा।
जबकि दान का सुझाव लक्ष्य पर है, आप इस मामले में एक मोडल व्यू कंट्रोलर का उपयोग नहीं कर सकते हैं क्योंकि एक सामान्य मोडल संपूर्ण स्क्रीन को कवर करता है, पैरेंट व्यू कंट्रोलर को अवरुद्ध करता है, भले ही आपके पास पारदर्शी के रूप में आपके दृश्य की पृष्ठभूमि हो (आप ' एप्लिकेशन के UIWindow में जो कुछ भी है उसे देखेंगे)।
यदि आप आईपैड पर ऐसा कर रहे हैं तो 2 मोडल प्रस्तुति शैलियों (UIViewModalPresentationStylePageSheet
और UIViewModalPresentationStyleFormSheet
) हैं जो कुछ समान कर सकते हैं, लेकिन वे आईफोन या आईपॉड टच पर काम नहीं करेंगे।
अंधेरे पृष्ठभूमि और आंशिक अस्पष्टता के साथ "छाया" दृश्य जोड़ें और दृश्य नियंत्रक के दृश्य पर सीधे जो भी दृश्य आप अग्रभूमि में होना चाहते हैं उसे जोड़ें। आप मानक UIView एनीमेशन ब्लॉक, या CoreAnimation का उपयोग करने में उन्हें एनिमेट कर सकते हैं।
एक और नोट, यदि आप उस छाया दृश्य को छूना चाहते हैं तो आप इसे touchesEnded:
जैसे टच विधियों में से एक को ओवरराइड करने के लिए या एक यूआईसींट्रोल में बदल सकते हैं जो एक स्पर्श की घटनाओं को प्राप्त कर सकते हैं UIButton, लेकिन पाठ, छाया, राज्य आदि के लिए अतिरिक्त विकल्प के बिना
आप सही हैं कि मैंने अपने जवाब में "मोडल" कहा था। मुझे वास्तव में किसी औपचारिक तरीके से "मॉड्यूल प्रस्तुत" दृश्य का अर्थ नहीं था। आप मूल रूप से अपना खुद का मोडल व्यू बना रहे हैं। –
उपरोक्त दो उत्तरों का काम तब होता है जब नए दृश्य की अपनी 'पृष्ठभूमि' होती है, यानी कोई पारदर्शिता नहीं होती है। समस्या जो मुझे यहां ले जाती है, इस तरह हल नहीं की जा सकती है, हालांकि, मैं जो करने की कोशिश कर रहा था वह यह है: मैं वास्तविक समय में वीडियो प्रदर्शित करने के लिए सामान्य AVCaptureVideoPreviewLayer
के साथ अपनी स्क्रीन पर AVCaptureSession
चला रहा हूं। मैं स्क्रीन का एक हिस्सा चुनना चाहता हूं (बाद में केवल इस भाग के साथ कुछ करने के लिए), और जब यह भाग चुना जाता है तो शेष वीडियो पूर्वावलोकन को मंद करना चाहते हैं। यह हैं कि यह दिखता है:
यह वह जगह है मैं यह कैसे हल: एक नया दृश्य जहां स्क्रीन को छुआ और वीडियो पूर्वावलोकन देखने के एक subview के रूप में जोड़ा जाता है के आधार पर बनाया जाता है। फिर, मैं स्क्रीन के बाकी हिस्सों को कवर करने के लिए पहले उल्लिखित पृष्ठभूमि रंग और अस्पष्टता के साथ 4 अतिरिक्त, गैर-ओवरलैपिंग आयताकार सबव्यूव्यू बनाता हूं। मुख्य दृश्य के सबव्यू होने के लिए मुझे इन सभी विचारों को स्पष्ट रूप से की आवश्यकता नहीं है, क्योंकि मुझे कहीं और स्क्रीन को स्पर्श करने और चयनित क्षेत्र को बदलने की क्षमता की आवश्यकता है।
मुझे यकीन है कि इसे हल करने के लिए और अधिक शानदार तरीके हैं, इसलिए अगर कोई जानता है कि कृपया कैसे टिप्पणी करें ...
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController<UIGestureRecognizerDelegate>
{
UIView *mainView;
UIView *dimBackgroundUIView;
UIView *customView;
UIButton *btn;
}
@end
#import "ViewController.h"
@interface ViewController()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
mainView = [[UIView alloc] init];
mainView.backgroundColor = [UIColor whiteColor];
[self.view addSubview:mainView];
[self addConstraintsForMainView];
btn = [[UIButton alloc] initWithFrame:CGRectMake(200, 200, 100, 30)];
[btn setTitle:@"Button" forState:UIControlStateNormal];
[btn setBackgroundColor:[UIColor blueColor]];
[btn addTarget:self action:@selector(showCustomView_Action:) forControlEvents:UIControlEventTouchUpInside];
[mainView addSubview:btn];
dimBackgroundUIView = [[UIView alloc] init];
dimBackgroundUIView.backgroundColor = [UIColor blackColor];
dimBackgroundUIView.alpha = 0.2;
}
-(void)removeCustomViewsFromSuperView {
if(dimBackgroundUIView)
[dimBackgroundUIView removeFromSuperview];
if(customView)
[customView removeFromSuperview];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)showCustomView_Action:(id)sender {
customView = [[UIView alloc] initWithFrame:CGRectMake(100, 200, 80, 80)];
customView.backgroundColor = [UIColor redColor];
[self.view addSubview:dimBackgroundUIView];
[self addConstraintsForDimView];
[self.view addSubview:customView];
UITapGestureRecognizer *tapped = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(removeCustomViewsFromSuperView)];
tapped.delegate=self;
tapped.numberOfTapsRequired = 1;
[customView addGestureRecognizer:tapped];
}
-(void) addConstraintsForDimView {
[dimBackgroundUIView setTranslatesAutoresizingMaskIntoConstraints:NO];
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:dimBackgroundUIView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeLeft multiplier:1 constant:0]];
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:dimBackgroundUIView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeRight multiplier:1 constant:0]];
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:dimBackgroundUIView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTop multiplier:1 constant:0]];
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:dimBackgroundUIView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeBottom multiplier:1 constant:0]];
}
-(void) addConstraintsForMainView {
[mainView setTranslatesAutoresizingMaskIntoConstraints:NO];
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:mainView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeLeft multiplier:1 constant:0]];
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:mainView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeRight multiplier:1 constant:0]];
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:mainView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTop multiplier:1 constant:0]];
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:mainView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeBottom multiplier:1 constant:0]];
}
@end
ध्यान दें: आप Xcode पर ग्राफिकल इंटरफेस का उपयोग करके कोड का अनुकूलन कर सकते, लेकिन मैं यह
तो विचार है परीक्षण करने के लिए सक्षम होने के लिए प्रोग्राम के रूप में कोड लिखना पड़ा करने के लिए:
- सेट करने के बजाय पृष्ठभूमि रंग को ब्लैक और सेट अल्फा 0.1 या 0.2 या पर UIView नाम दें जिसे आप चाहते हैं (dimBackgroundUIView)
- जब आपको पृष्ठभूमि को मंद करने की आवश्यकता होती है तो कोड की यह 2 पंक्ति जोड़ें: [self.view addSubview: dimBackgroundUIView]; [स्वयं addConstraintsForDimView];
- और जब आप dimming पृष्ठभूमि को हटाना चाहते हैं तो कोड की यह 2 पंक्ति जोड़ें: यदि (dimBackgroundUIView) [dimBackgroundUIView removeFromSuperview];
- 1. क्षेत्र प्रबंधक में एक दृश्य छुपाएं, जब कोई अन्य दृश्य दिखाया गया है
- 2. पृष्ठभूमि दृश्य रंग आईओएस
- 3. किया गया है ReceiveMemory चेतावनी/viewDidUnload जब एक दृश्य नियंत्रक दिखाया जाता है?
- 4. QML: दिखाया गया है qml स्क्रीन
- 5. पृष्ठभूमि-छवि शैली के साथ एचटीएमएल ईमेल दिखाया नहीं गया
- 6. जब एक iOS आवेदन पृष्ठभूमि
- 7. गलत wp_nav_menu दिखाया गया
- 8. मैं कैसे के रूप में ऊपर दिखाया गया एक दृश्य की एक छवि है छवियों
- 9. UILocalNotification आईओएस 5 मुद्दा (कोई चेतावनी नहीं दिखाया गया)
- 10. यदि UIAlertView दिखाया गया है तो आईओएस पर कोई सूचना है?
- 11. कैसे जिस पर एक JDialog दिखाया गया है
- 12. ProgressDialog नहीं दिखाया जाता है जब AsyncTask.get()
- 13. पृष्ठभूमि में होने के बाद UIViewController दृश्य कब दिखाया जाता है?
- 14. सीएसएस टेबल्स, दिखाया गया है सामग्री
- 15. प्रारंभ में छुपा मेनू इटैम नहीं दिखाया गया जब सेट (वास्तविक) सेट किया गया है
- 16. स्पष्ट पृष्ठभूमि के साथ संवाद प्रारूप (मंद नहीं)
- 17. विम - मंद निष्क्रिय स्प्लिट पैन
- 18. अक्षम उपयोगकर्ता एक दृश्य आईओएस
- 19. हाइबरनेट जब एक दृश्य
- 20. आईओएस एक ही दृश्य नियंत्रक
- 21. आईओएस पृष्ठभूमि ऑडियो एक वेब ऐप में
- 22. आईओएस: छवि लोड करते समय ब्लैक स्टेटस बार दिखाया गया है
- 23. iPhone स्क्रीन मंद
- 24. समूह तालिका दृश्य पृष्ठभूमि रंग ios में पदावनत किया गया है 6,0
- 25. आईओएस समय पृष्ठभूमि प्रसंस्करण
- 26. बचत आईओएस अनुप्रयोग दृश्य राज्य
- 27. @ Html.ValidationMessageFor() कस्टम सत्यापन मैसेज हमेशा दिखाया गया
- 28. कीबोर्ड दिखाया गया तत्वों की स्थिति
- 29. जब उपयोगकर्ता को यूआई दिखाया जाता है तो ईवेंट?
- 30. आईओएस ढाल transpareny एनिमेटेड दृश्य
क्या आप इंटरफ़ेस बिल्डर में वह लेआउट कर सकते हैं, फिर प्रोग्रामिंग रूप से तब तक छुपाएं जब तक आप इसे नहीं चाहते? या छुपाए जाने पर भी यह हस्तक्षेप करेगा? – ToolmakerSteve