I want to reuse header
section all view controller scene
.header section mean green view and label (\"AMAR LIFE\")
Here is my may 1st
Try the following steps to achieve your header visible on all views.
Step 1: Drag a navigationController into your storyBoard and delete tableView rootViewcontroller comes with the naviagtionController.Connect your NavigationController to your tabBarController.Now,NavigationController available to all your view.
Note: Your storyBoard layout should be look like a below image..
Step 2: Implement following code to your FirstTabBarController.
override func viewDidLoad() {
super.viewDidLoad()
// Apply transparency to NavigationBar.
navigationController?.navigationBar.setBackgroundImage(UIImage(), for: UIBarMetrics.default)
navigationController?.navigationBar.shadowImage = UIImage()
//Setting up scanView background
let barView = UIView(frame: CGRect(x:0, y:0, width:view.frame.width,height: (navigationController?.navigationBar.frame.height)! + UIApplication.shared.statusBarFrame.height))
barView.backgroundColor=UIColor.green // set any colour you want..
barView.layer.borderColor = UIColor.black.cgColor
barView.layer.borderWidth = 3
navigationController?.navigationBar.addSubview(barView)
//Setting up labelView
let label = UILabel()
label.frame = CGRect(x:25, y:5, width:view.frame.width - 50 , height:((navigationController?.navigationBar.frame.height)! + UIApplication.shared.statusBarFrame.height) - 10)
label.text = "AMAR LIFE"
label.textAlignment = .center
label.textColor = .black
label.font = UIFont(name: "HelveticaNeue-medium", size: CGFloat(40))
label.layer.borderColor = UIColor.black.cgColor
label.layer.borderWidth = 3
barView.addSubview(label)
}
Output: