在CATransform3DMakeScale之后,UIBarButtonItem不起作用

时间:2019-12-05 14:47:27

标签: swift uibutton uibarbuttonitem swift5

我有一个内部带有imageButton的UIBarButtonItem,但是图像的渲染效果不好,因此我在其上应用了CATransform3DMakeScale,但该UIBarButtonItem不再起作用,您无法单击 >。

这是UIBarButtonItem的代码:

let importButton = UIButton(frame: CGRect(x: 0, y: 0, width: 22, height: 22))
// Image
importButton.setBackgroundImage(UIImage(named: "ic_action_import_base"), for: .normal)

// The critical transform
importButton.layer.transform = CATransform3DMakeScale(1.8, 1.8, 0)

// Action
importButton.addTarget(self, action: #selector(importButtonTriggered), for: .touchUpInside)

let importUIBarButton = UIBarButtonItem(customView: importButton)
// Constraints for the size
let importCurrWidth = importUIBarButton.customView?.widthAnchor.constraint(equalToConstant: 22)
importCurrWidth?.isActive = true
let importCurrHeight = importUIBarButton.customView?.heightAnchor.constraint(equalToConstant: 22)
importCurrHeight?.isActive = true

不进行转换,然后进行转换的渲染: Without Transform With Transform

是否有人想拥有并且具有可点击的UIBarButtonItem的良好呈现效果?

0 个答案:

没有答案
相关问题