、MenuViewItemは素直のUIViewのサブクラスようです。この場合、ビューのレイヤーにサブレイヤを追加することで、あなたが望むことができます。あなたが持っていたのであればMenuItemViewはmyMenuItemViewと呼ばれる:
let parallelogramLayer : CAShapeLayer = CAShapeLayer()
parallelogramLayer.fillColor = UIColor.white.cgColor
parallelogramLayer.frame = bounds
let parallelogramPath : UIBezierPath = UIBezierPath()
parallelogramPath.move(to: CGPoint(x: 10, y: 0))
parallelogramPath.addLine(to: CGPoint(x: bounds.width, y: 0))
parallelogramPath.addLine(to: CGPoint(x: bounds.width - 10, y: bounds.height))
parallelogramPath.addLine(to: CGPoint(x: 0, y: bounds.height))
parallelogramPath.close()
paralellogramLayer.path = parallelogramPath.cgPath
myMenuViewItem.layer.addSublayer(parallelogramLayer)
が明らかにメニュー項目がアクティブであるかどうかによって、層を追加/削除する必要があるだろうし、うまくいけば、これはあなたのアイデアを提供します。希望が役立ちます。
申し訳ありません、強調表示されたメニュー項目の背景に白い平行四辺形を追加することを意味しますか? – Sparky
はい白い平行四辺形を強調表示されたメニュー項目の背景に追加することを意味します。 –