i have View with alpha .5 with equal height and width to screen . I have to implement scroll view behind that view, Could anyone tell me how to implement it ?
As of Swift 5:
You can set the ScrollView as a child of the View in the Storyboard editor. Simply drag the ScrollView inside the View. The tree should look like the following:
View
ScrollView
< ... >
The ScrollView should be scrollable.
Related
I have created a view and the content is larger than the screen. How do I add this view as a subview of a scrollview? For some reason I can't do this in Document Outline. It will only let me add the scrollview as a subview of the existing view.
Select your view in Interfacebuilder and then use the menu command Editor:Embed In:Scroll View
So I have the following view hierarchy :
A full size scrollView in my viewController's view with the following constraints :
These are the constraints on containerView (ignore the second last one, its a hacky semi-fix for my problem):
I have the status bar, the navigation bar and the tab bar visible.
The thing is that when I set a breakpoint to check the scrollView's contentInset, it shows 64 on top and 49 on bottom, left and right are zero.
There is no way to set contentInset in IB, I tried setting it in an IBAction to UIEdgeInsetZeio, but that didn't fix it either. This is screwing up my scrollview by adding space above and below my contentView, how can I fix this?
By default the view controller extends the view under the top navigation bar so your content will blur under a translucent navigation bar. This is controlled by edgesForExtendLayout which is managed in Storyboard via the Extend Edges setting.
By default, the scrollview will automatically adjust its content inset so the content appears below the top layout guide. This is controlled by automaticallyAdjustsScrollViewInsets which is also managed in Storyboard.
What you did was constrain the top of your scroll view to the top layout guide instead of the top of its superview. By doing this, you manually offset it by 64 points. However, the scrollview is still automatically insetting its content by 64 points, which is why you're seeing additional space above and below your scroll view.
Either constrain your scrollview to its superview (so its content scrolls under the top/bottom bars), or disable the view controller from automatically adjusting the scroll view inset.
I was creating a scrollview contains an image view and a dynamic height label,
here's my hierarchy in xib file:
-> view (originally existed view when xib file created )
--> scroll view
---> content view
----> image + label (dynamic height depend on its content)
I set the content view's height depend on the label's height
,and then set the scroll view's content size(scrollable area) to the content view's frame size
I expect the content view and the scroll view both has equal width to the top view
(top view's width is flexible when device got rotated, and also are the content view & scroll view's)
and only the vertical direction is scrollable.
yet I totally have no idea dealing with the autolayout,
once I set the content view's constraints to the top view, the scrolling becomes disable,
but after I remove all constraints the content view'd be scrolled like a bouncing block...
(sorry for not providing any picture but only description for my question due to low reputation)
been mad about this for a whole day
any help would be appreciated.
firstly, i want add 3 subviews with textview, image also edittext ;
view1 ; image,
view 2 : text, image,
view 3 : text, label
i want to scroll with async or with swipe
i used image scroll but can't find subviews
thanks for sharing
You can use an UIScrollView, or an UIPageViewController. Both will work, but the custom scroll view may be a bit simpler.
My viewController already have main scrollView for show content as subview in Storyboard. After that i'm try to add new subview for show image gallery (UIScrollView) that also work fine. then when i'm close image gallery view, the main scrollView content size decrease down to fit of the viewController bounds. How can i avoid that situation? Thank you in advance.