Closed stasberkman closed 7 years ago
Hi @stasberkman ,
You can create a xib file with the custom view (with background view and label) as required. And set this custom view as the navigationItem.titleView for each of the View Controllers.
Code snippet follows:
let firstViewController = storyboard
.instantiateViewController(withIdentifier: "FirstViewController")
firstViewController.title = "FIRST"
let view = UIView()
view.layer.masksToBounds = true
view.contentMode = .scaleAspectFit
if let customView = Bundle.main.loadNibNamed("TabCustomView", owner: self, options: nil)?.first as? TabCustomView {
customView.frame = CGRect(x: 0, y: 0, width: 30, height: 5 )
customView.layer.masksToBounds = true
customView.contentMode = .scaleAspectFit
view.addSubview(customView)
firstViewController.navigationItem.titleView = view
}
let segmentController = SJSegmentedViewController()
segmentController.segmentControllers = [firstViewController, secondViewController]
Hope this helps!
Yes but if i want a gradient background color for the all segment view, i don't have a control of that.
for example this behaivour:
Currently, we don't have a direct way to work this out, We will try to include this in a new update.
Hi
I want to make the background color of the tabs view to be gradient, how can i set one custom view for all the tabs
Thanks