如何在另一个视图中获取视图的框架? [英] How to get the frame of a view inside another view?
本文介绍了如何在另一个视图中获取视图的框架?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 self.view
(主视图)中有一个 UIImageView
,里面有一个的UIButton
。我想知道在 self.view
中 UIButton
的框架是什么,而不是 UIImageView
。
I have an UIImageView
in the self.view
(the main View) and inside it there is a UIButton
. I want to know what's the frame of UIButton
in self.view
not in UIImageView
.
推荐答案
我猜您正在寻找这种方法
I guess you are looking for this method
// Swift
let frame = imageView.convert(button.frame, to: self.view)
// Objective-C
CGRect frame = [imageView convertRect:button.frame toView:self.view];
这篇关于如何在另一个视图中获取视图的框架?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文