【问题标题】:How to get the position of rightBarButtonItems of navigationItem?如何获取navigationItem的rightBarButtonItems的位置?
【发布时间】:2021-04-24 15:06:59
【问题描述】:

我有一系列导航项。我正在尝试在其中一个导航项附近添加一个弹出框。我没有在按钮中使用 CustomView

navigationItem.rightBarButtonItems = [infoBarButtonItem, aboutBarButtonItem]

let barButtonView = navigationItem.rightBarButtonItems?.first

如何获取 barButtonView 的 CGPoints?

【问题讨论】:

    标签: swift


    【解决方案1】:

    我认为您正在尝试获取私人数据。在 iOS 11 之前,可以使用 value(forKey:) func 获取 UIBarButtonItem 的视图,但它不再为您提供视图。据我所知,唯一的方法是使用自定义视图制作一个条形按钮项,并保留对该自定义视图的引用,以便您稍后获得它的位置。 Apple 开发者论坛上也有类似的帖子,所以我会附上链接以防您好奇。 Apple Developer Forum Thread九年前在StackOverflow上也有类似的问题Old StackOverflow question

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-29
      • 1970-01-01
      • 1970-01-01
      • 2020-04-04
      相关资源
      最近更新 更多