我试图给这个条形按钮项目标签一个绿色背景,然后一些角落半径。
utcLbl.frame = CGRect(x: 0, y: 0, width: 100, height: 20)
utcLbl.text = "\(dateFormatter.string(from: Date())) UTC"
utcItem.customView = utcLbl
utcLbl.backgroundColor = UIColor.green
utcLbl.layer.cornerRadius = 20
utcLbl.textAlignment = .center
self.navigationItem.setLeftBarButtonItems([utcItem], animated: true)
这是密码和照片
任何帮助使绿色背景有一个角落半径。
最佳答案
你需要剪贴画界或面具界
utcLbl.frame = CGRect(x: 0, y: 0, width: 100, height: 20)
utcLbl.text = "\(dateFormatter.string(from: Date())) UTC"
utcItem.customView = utcLbl
utcLbl.backgroundColor = UIColor.green
utcLbl.layer.cornerRadius = 20
utcLbl.textAlignment = .center
utcLbl.layer.masksToBounds = true // Or utcLbl.clipsToBounds = true
self.navigationItem.setLeftBarButtonItems([utcItem], animated: true)