I have a Tabbar which is created by SwiftUI, but I use different images for different status of selected Tabbar(selected and unselected), how can I do that.
I tried to change image name in
TabView1().onAppear() {
tabImageName1 = "image1_active"
tabImageName2 = "image2"
tabImageName3 = "image3"
tabImageName4 = "image4"
}
seems this not worked, and I think it's not so elegant, how can I change the image rightly, do we have better ways to do thing like this?
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I need to create a section header for a tableview, and I don't want to create it in single Xib, I added one in storyboard, but the header need some customization, so I create a file looks like this:
class CustomizedTipsView: UITableViewHeaderFooterView {
@IBOutlet weak var tipTitle: UILabel!
@IBOutlet weak var tipContent: UILabel!
}
And I want to use the header in viewForHeaderInSection func like this:
if let header = tableView.dequeueReusableHeaderFooterView(withIdentifier: "CustomizedTipsView") as? CustomizedTipsView {
header.tipTitle.text = "1"
header.tipContent.text = "2"
}
if I register the cell, it crash, if not, the cell always returns nil.
//crash
mainTableView.register(UINib(nibName: "CustomizedTipsView", bundle: nil), forHeaderFooterViewReuseIdentifier: "CustomizedTipsView")
//crash too
mainTableView.register(CustomizedTipsView.self, forHeaderFooterViewReuseIdentifier: "CustomizedTipsView")
Do I have to use the UITableViewCell instead of simple CustomizedTipsView for view from storyboard?
Thank you for your help!