I'm trying to make a custom UIBarButtonItem
class to just change the font and the color of the Bar Button I have added to my View controllers. and I have more than 20 Buttons that need to be changed.
How could I do this by just adding a custom UIBarButtonItem
Class from the (Identity Inspector) story board ?
Create class for UIBarButtonItem
class CustomBarButton: UIBarButtonItem {
override func awakeFromNib() {
style = .plain
tintColor = .red
//Set font name and size
guard let font = UIFont(name: "Helvetica-Bold", size: 19) else {
return
}
setTitleTextAttributes([NSAttributedStringKey.font:font], for: .normal)
}
}
Set CustomBarButton class to UIBarButtonItem from Identity Inspector.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.