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

后端 未结 4 2031
攒了一身酷
攒了一身酷 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:15

    Something like this? might be totally wrong, dint really thinkt it through ;p

    CGRect frame = CGRectMake((self.view.frame.origin.x-imageview.frame.origin.x) +btn.frame.origin.x,
                              (self.view.frame.origin.y.imageview.frame.origin.y)+btn.frame.origin.y,
                              btn.frame.size.width,
                              btn.frame.size.height);
    

    I don't know if theres any easier way.

提交回复
热议问题