How to get the frame of a view inside another view?

后端 未结 4 2025
攒了一身酷
攒了一身酷 2020-12-04 16:38

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 UI

4条回答
  •  眼角桃花
    2020-12-04 17:08

    I guess you are looking for this method

    – convertRect:toView:

    // Swift
    let frame = imageView.convert(button.frame, to: self.view)
    
    // Objective-C
    CGRect frame = [imageView convertRect:button.frame toView:self.view];
    

提交回复
热议问题