0

I have a scrollview. I need to add another view as a subview of this scrollview. The subviews frame is

(-13,20,200,90)

So while adding this view to scrollview the as subviews origin is negative some portion of the subview gets clipped.

As a solution i tried setting

[scrollView setClipToBounds:NO]

But this causes the contents in scrollview overflowing outside the frame of scrollview.

As a next step I tried changing the bounds of the scrollview like this

CGRect rect = container.scroller.bounds;
container.scroller.bounds = CGRectMake(rect.origin.x-205, rect.origin.y, rect.size.width+205, rect.size.height);

But this shifts the scrollviews position to right.

Basically I want to add an item outside the drawable areas of a UIScrollview without the subview getting clipped.

How can I achieve this in IOS?

Zach
  • 9,989
  • 19
  • 70
  • 107
  • "But this causes the contents in scrollview overflowing outside the frame of scrollview." -isn't that what you wanted in the first place? – DanMoore Apr 02 '14 at 18:56
  • I have a textview and imageview in scrollview. Whe a longpress is detected in imageview i need to display a popover screen. based on user touch location the popover can appear completely within the scrollview bounds or some portion of the popover outside the bounds either on left or right side. I dont want the text visible outside the bounds on top and bottom portions. – Zach Apr 02 '14 at 19:25

2 Answers2

0

Add the content in the self.view instead of the scrollView

EhTd
  • 3,260
  • 4
  • 19
  • 18
0

Width has to be increased as doubled x offset. So if you are moving bounds to left by 205, you have to increase a width by 410 to keep it centered.

original:
----===----
result:
---====----
intent:
---=====---
Bohdan Orlov
  • 274
  • 3
  • 3