要删除UIBarButtonItem旁边的填充,您可以使用以下方法:
let customButton = UIButton(type: .system)
customButton.setImage(UIImage(named: "your_image_name"), for: .normal)
customButton.frame = CGRect(x: 0, y: 0, width: 30, height: 30)
let customBarButtonItem = UIBarButtonItem(customView: customButton)
navigationItem.rightBarButtonItem = customBarButtonItem
navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
navigationController?.navigationBar.shadowImage = UIImage()
navigationController?.navigationBar.isTranslucent = false
这样,您就可以删除UIBarButtonItem旁边的填充,并使其看起来更加美观。
领取专属 10元无门槛券
手把手带您无忧上云