1.我想做一个动画,需要知道rightBarButtonItem对应self.view中的位置,即:
CGPoint toPoint = [self.navigationController.navigationBar convertPoint:self.navigationItem.titleView.center toView:self.view];
但是获取到的位置坐标始终不正确:
2.问题是:
怎么能够获取到导航栏中的各个navigationItem对应在self.view中的位置呢?
self.view is a view placed in the navigation controller, and the navigation bar is the same, so they are equal. It does not mean that the navigation bar is a subview of self.view. Naturally, there is no way to calculate the navigation bar. The position of the sub-items in self.view.
I think what you want to calculate is the position of the item in the window or navigationController.view, right?
You can use view debugging to see the hierarchical relationship between various views.
frameInNaviView is what you need
Found through testing:
This can indeed get the correct position; but after testing on the iPad, it was found that the same code got the result {{0, 0}, {44, 44}}. This seems to have led to a new Question: Why is it correct on iPhone but not on iPad?