मैं पूरी तरह से पारदर्शी UIToolbarऔर / या चाहता हूं UINavigationBar। मैंने पूर्व और बाद के आईओएस 5 के लिए सुझाए गए विभिन्न झुकावों की कोशिश की है, लेकिन कोई भी काम नहीं करता है।
IOS 7 में इसे कैसे पूरा किया जा सकता है?
मैं पूरी तरह से पारदर्शी UIToolbarऔर / या चाहता हूं UINavigationBar। मैंने पूर्व और बाद के आईओएस 5 के लिए सुझाए गए विभिन्न झुकावों की कोशिश की है, लेकिन कोई भी काम नहीं करता है।
IOS 7 में इसे कैसे पूरा किया जा सकता है?
जवाबों:
UIToolbarself.toolbar.setBackgroundImage(UIImage(),
forToolbarPosition: .any,
barMetrics: .default)
self.toolbar.setShadowImage(UIImage(), forToolbarPosition: .any)
UINavigationBarself.navigationBar.setBackgroundImage(UIImage(), for: .default)
self.navigationBar.shadowImage = UIImage()
self.navigationBar.isTranslucent = true
UIToolbarself.toolbar.setBackgroundImage(UIImage(),
forToolbarPosition: UIBarPosition.Any,
barMetrics: UIBarMetrics.Default)
self.toolbar.setShadowImage(UIImage(),
forToolbarPosition: UIBarPosition.Any)
UINavigationBarself.navigationBar.setBackgroundImage(UIImage(), forBarMetrics: UIBarMetrics.Default)
self.navigationBar.shadowImage = UIImage()
self.navigationBar.translucent = true
UIToolbar[self.toolbar setBackgroundImage:[UIImage new]
forToolbarPosition:UIBarPositionAny
barMetrics:UIBarMetricsDefault];
[self.toolbar setShadowImage:[UIImage new]
forToolbarPosition:UIBarPositionAny];
UINavigationBar[self.navigationBar setBackgroundImage:[UIImage new]
forBarMetrics:UIBarMetricsDefault];
self.navigationBar.shadowImage = [UIImage new];
self.navigationBar.translucent = YES;
स्थापना translucentके लिए YESनेविगेशन पट्टी पर एक व्यवहार में चर्चा की वजह से, काम कर देता है UINavigationBarप्रलेखन। मैं यहाँ प्रासंगिक अंश की रिपोर्ट करूँगा:
यदि आप इस संपत्ति को
YESएक अपारदर्शी कस्टम पृष्ठभूमि छवि के साथ एक नेविगेशन बार पर सेट करते हैं , तो नेविगेशन बार छवि से 1.0 से कम सिस्टम अपारदर्शिता लागू करेगा।

iOS 7सिम्युलेटर से है
यदि आप इसे संपूर्ण ऐप के माध्यम से करना चाहते हैं तो आपको UIAppearance प्रॉक्सी (iOS5 +) का उपयोग करना चाहिए:
UINavigationBar *navigationBarAppearance = [UINavigationBar appearance];
navigationBarAppearance.backgroundColor = [UIColor clearColor];
[navigationBarAppearance setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
navigationBarAppearance.shadowImage = [[UIImage alloc] init];
UINavigationControllerउपवर्गों के साथ काम करने के लिए भी सेट कर सकते हैं - यानी, जो आप चाहते हैं कि यह व्यवहार लागू हो।
@implementation MyCustomNavigationBar
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self setup];
}
return self;
}
- (id)initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder];
if (self) {
[self setup];
}
return self;
}
- (void)setup {
[self setupBackground];
}
- (void)setupBackground {
self.backgroundColor = [UIColor clearColor];
self.tintColor = [UIColor clearColor];
// make navigation bar overlap the content
self.translucent = YES;
self.opaque = NO;
// remove the default background image by replacing it with a clear image
[self setBackgroundImage:[self.class maskedImage] forBarMetrics:UIBarMetricsDefault];
// remove defualt bottom shadow
[self setShadowImage: [UIImage new]];
}
+ (UIImage *)maskedImage {
const float colorMask[6] = {222, 255, 222, 255, 222, 255};
UIImage *img = [UIImage imageNamed:@"nav-white-pixel-bg.jpg"];
return [UIImage imageWithCGImage: CGImageCreateWithMaskingColors(img.CGImage, colorMask)];
}
@end