0

I am using CGRectIntersection to get the common visible frame availbale from subview UIView.I have an uiview shown as pullup view on screen(say screen1),where uiview(pullUpView) is added as subview to screen1.When anyone presses button on screen1 it slides up pullUpView partially.So to get the frame of partially visible view I am using:

CGRect visible_frame = CGRectIntersection(pullUpView.frame,screen1.bounds).

After getting visible_frame I am adding UIButton at the bottom of visible_frame like this

CGFloat y_pos = visibleFrame.size.height ;
UIButton * button = [[UIButton alloc]initWithframe:CGRectMake(x,y_pos,visible_frame.size.width),30];

But it adds button approximately 50 pixel above than the desired bottom of visible_frame.

What is wrong in above calculation can anybody please point out.

David Berry
  • 40,941
  • 12
  • 84
  • 95
deep
  • 99
  • 1
  • 2
  • 8
  • Provide annotated screenshots, please. My first thought is that you are pulling `CGRect`s from two different frames of reference. – Avi Mar 15 '16 at 07:21
  • Please help me understand what do u mean by two different frame of references. – deep Mar 16 '16 at 05:08
  • A view's frame is an external frame of reference. It describes its place within it's superview. The bounds describes the internal coordinate system of the view, which it presents to its subviews. Don't mix the two, unless you are sure of what you are doing. – Avi Mar 16 '16 at 05:29
  • Thanks for clarification. And true frames and bounds are different. But even if I use frame of superview instead of bound it gives the same result. – deep Mar 16 '16 at 05:34
  • My bad I forgot to mention that I am moving screen1 up(hiding navigation bar) when sliding pullUpView Up. So that could be one of the reason, that its giving wrong frame. – deep Mar 16 '16 at 06:14
  • Ok so I solved my problem and posting it as it may help someone too. Whenever I was sliding pullupView(UIView as subview) on screen1(controller screen) I was sliding Screen1 Up by 50 pixels(by animating its center 50 pixel Up without changing its height). As a result pullUpView which was presented on screen1 ,its lowest 50 pixels were sitting out of window so it was not responding to that area. So i solved it by increasing the height of screen1 by 50 pixel whenever i was sliding up and pullUpView and button (which was added at the bottom of pullUpView) started responding. – deep Mar 17 '16 at 10:03

0 Answers0