Swift 3 (iOS 10)
Trong suốt UIToolbar
self.toolbar.setBackgroundImage(UIImage(),
forToolbarPosition: .any,
barMetrics: .default)
self.toolbar.setShadowImage(UIImage(), forToolbarPosition: .any)
Trong suốt UINavigationBar
self.navigationBar.setBackgroundImage(UIImage(), for: .default)
self.navigationBar.shadowImage = UIImage()
self.navigationBar.isTranslucent = true
Swift <3
Trong suốt UIToolbar
self.toolbar.setBackgroundImage(UIImage(),
forToolbarPosition: UIBarPosition.Any,
barMetrics: UIBarMetrics.Default)
self.toolbar.setShadowImage(UIImage(),
forToolbarPosition: UIBarPosition.Any)
Trong suốt UINavigationBar
self.navigationBar.setBackgroundImage(UIImage(), forBarMetrics: UIBarMetrics.Default)
self.navigationBar.shadowImage = UIImage()
self.navigationBar.translucent = true
Objective-C
Trong suốt UIToolbar
[self.toolbar setBackgroundImage:[UIImage new]
forToolbarPosition:UIBarPositionAny
barMetrics:UIBarMetricsDefault];
[self.toolbar setShadowImage:[UIImage new]
forToolbarPosition:UIBarPositionAny];
Trong suốt UINavigationBar
[self.navigationBar setBackgroundImage:[UIImage new]
forBarMetrics:UIBarMetricsDefault];
self.navigationBar.shadowImage = [UIImage new];
self.navigationBar.translucent = YES;
Thảo luận
Đặt translucentthành YEStrên thanh điều hướng thực hiện thủ thuật, do một hành vi được thảo luận trong UINavigationBartài liệu. Tôi sẽ báo cáo ở đây phần liên quan:
Nếu bạn đặt thuộc tính này YEStrên thanh điều hướng có hình nền tùy chỉnh mờ đục, thanh điều hướng sẽ áp dụng độ mờ hệ thống nhỏ hơn 1,0 cho hình ảnh.
Kết quả cuối cùng
