提问人:Ayoub 提问时间:9/1/2023 最后编辑:Ayoub 更新时间:9/1/2023 访问量:34
如何在所选选项卡栏项图像后面添加这些胶囊形状
How to add these capsule shape behind the selected tab bar item image
问:
我想制作一个具有以下功能的标签栏:
- 选定的标签栏项目仅在其图标周围具有此胶囊形状,链接到所需的标签栏
我正在以编程方式创建标签栏。你能帮我写代码吗?
到目前为止我所取得的成就的屏幕截图:链接到屏幕截图
这是到目前为止的代码
class TabBarViewController: UITabBarController {
override func viewDidLoad() {
super.viewDidLoad()
//MARK: Initializing tab-bar viewControllers
let prayerVC = initiateViewController.initiatePrayerVC()
let alarmVC = initiateViewController.initiateAlarmVC()
let settingsVC = initiateViewController.initiateSettingsVC()
//MARK: tab bar item text attributes
let attributes: [NSAttributedString.Key: Any] = [
.font: UIFont(name: "Roboto-Medium", size: UIFont.systemFont(ofSize: 12).pointSize) as Any
]
//MARK: edit tab bar appearance & attributes
UITabBarItem.appearance().setTitleTextAttributes(attributes, for: .normal)
//MARK: adding Title and image for each Tab bar item (viewcontroller)
prayerVC.tabBarItem.title = text_international.prayer_times
alarmVC.tabBarItem.title = text_international.alarm
settingsVC.tabBarItem.title = text_international.settings
prayerVC.tabBarItem.image = UIImage(named: "IconPrayer")
alarmVC.tabBarItem.image = UIImage(named: "IconAlarm")
settingsVC.tabBarItem.image = UIImage(named: "IconSettings")
//MARK: adding View Controllers to the tab bar
self.setViewControllers([prayerVC,alarmVC,settingsVC], animated: false)
}
答: 暂无答案
评论