Ios 如何在酒吧按钮项目上贴标签?
我想在导航栏上制作日历Ios 如何在酒吧按钮项目上贴标签?,ios,swift,Ios,Swift,我想在导航栏上制作日历 喜欢图片上的内容 但我不知道如何在日历图像上贴标签 请帮帮我 谢谢使用以下代码在导航栏中添加图像和标签: let button = UIButton(type: .custom) button.setImage(UIImage(named: "calenderImage"), for: .normal) button.addTarget(self, action: Selector(("buttonAction")), for: .to
喜欢图片上的内容
但我不知道如何在日历图像上贴标签
请帮帮我
谢谢使用以下代码在导航栏中添加图像和标签:
let button = UIButton(type: .custom)
button.setImage(UIImage(named: "calenderImage"), for: .normal)
button.addTarget(self, action: Selector(("buttonAction")), for: .touchUpInside)
button.frame = CGRect(x: 0, y: 0, width: 53, height: 31)
let label = UILabel(frame: CGRect(x: 3, y: 5, width: 50, height: 20))// set position of label
label.font = UIFont(name: "Arial-BoldMT", size: 16)// add font and size of label
label.text = "your date number"
label.textAlignment = .center
label.textColor = UIColor.black
label.backgroundColor = UIColor.clear
button.addSubview(label)
let barButton = UIBarButtonItem(customView: button)
self.navigationItem.rightBarButtonItem = barButton
您想在该图像上显示当前日期,还是只想在图像上显示任何数字?它正在工作!谢谢你