我正在尝试创建一个类似于Android在导航栏中看到的溢出菜单。这是一个例子:
我通过创建隐藏的UIView来完成此操作,除非单击特定按钮。这一切都运行正常,但问题是将溢出菜单限制在按钮上。
在溢出菜单中,我试图将溢出菜单限制为按钮(此按钮是UIBarButtonItem的自定义视图):
topAnchor.constraint(equalTo: button.topAnchor).isActive = true
leftAnchor.constraint(equalTo: button.leftAnchor).isActive = true
我收到以下错误:
UIButton:0x7f84974081e0.top"> because they have no common ancestor. Does the constraint or its anchors reference items in different view hierarchies? That's illegal.
如何将UIView相对于导航栏按钮项自定义视图定位?
备注: