テキストとイメージを含むボタンがありますが、イメージにコーナーの半径を持たせたいと思います。コーナーの半径をボタンに適用しようとすると、それは正しいと思われるボタン全体に適用されます。代わりに画像の角の半径を設定するにはどうすればよいですか?スウィフト - UIButtonにネストされたイメージの角の半径を設定する
let titleButton = UIButton()
titleButton.frame = CGRect(x: 0, y: 0, width: 100, height: 40)
titleButton.setTitle("display name", for: .normal)
titleButton.setImage(#imageLiteral(resourceName: "imgName"), for: .normal)
titleButton.layer.masksToBounds = true
titleButton.layer.cornerRadius = titleButton.frame.width/2
self.navigationItem.titleView = titleButton