swift: how to show the vertical indicator of scrollView? - ios

I want to show vertical indicator of UIScrollView when user move to controller and not start scrolling. Like in UITableView when user move to tableView vertical indicator shows automatically even if the user not start scrolling. How to do it?

You can use the function flashScrollIndicators.
Documentation:
Displays the scroll indicators for a short time. This should be done whenever you bring the scroll view to front.

Use This Code:
self.ScrollView.showsVerticalScrollIndicator = true
Make sure you have set UIScrollViewDelegate correctly,
self.ScrollView.delegate = self

You can enable and disable it from storyboard interface.
Vertical checkbox handles vertical scroll indicator
Horizontal checkbox handles horizontal scroll indicator
The same can be set programatically like
// For vertical scroll indicator
scrollView.showsVerticalScrollIndicator = true
// For horizontal scroll indicator
scrollView.showsHorizontalScrollIndicator = true

Try to use scrollView.flashScrollIndicators()

Related

Swift: Hide Scrollview header

I would like to hide the header of my scrollview.
I have a scrollview
//Contains everything inside the view
let scrollView = UIScrollView()
scrollView.alwaysBounceVertical = true
scrollView.translatesAutoresizingMaskIntoConstraints = false
scrollView.showsHorizontalScrollIndicator = false
which spans across the whole width and height of my view. When scrolling down, a weird header appears and blocks a bit of the scroll view content. I would like to hide that overlay. The worst thing is, that in bright mode, the overlay is white. That clashes with my colors. How do I go about removing it?
The overlay is the navigation bar - it appears as soon as you scroll. To hide it completely, you can set navigationController?.setNavigationBarHidden(true, animated: false). Or, you can pass in a transparent appearance for navigationController?.navigationBar.standardAppearance.

UIStackView subview contents visible during hiding animation

I am using a UIStackView for my layout. In that stack view, when I press a button I want to hide one of the subviews. That subview contains a couple buttons and a label. My issue is that during the hide animation, the buttons and label are visible until the vertical space from the subview is fully animated away.
Is there something I can do so that when I call subview.isHidden = true, the subview`s contents hide immediately at the beginning of the animation instead of at the very end of the animation?
use a custom stackView class. Use IBOutlets in the class to reference the buttons/text and write a function that hides your outlets when self.isHidden = true. Let me know if you need more explanation.
Besides hiding the buttons and content view with an animation you could try changing the background color from clear on the views inside the stackview to the same color as the background on your view. This still might not look great but it would be better.
Obviously animation would be something like the code below but give background color on your content views in the stackview a shot.
UIView.animate(withDuration: 0.1, animations: {
//yourContentHoldingView.alpha = 0
})

Always shown vertical and horizontal scroll indicator on a uiwebview

i get html text and images from web services and load in webview. i need to add scroll indicator for vertical and horizontal scroll bar for view text and images. some of the large text and images user didn't notice full information. shown scroll indicators after finish loading webview
Starting iOS 5.0 onwards, you can customize the scrolling behavior of UIWebView by accessing the 'scrollview' property to achieve the desired functionality:
Use the scroll view of the webview like this:
[webView.scrollView setShowsHorizontalScrollIndicator:YES];
[webView.scrollView setShowsVerticalScrollIndicator:YES];
You can do one thing that ,use this
(void) webViewDidFinishLoad:(UIWebView *)webView){
[webView.scrollView flashScrollIndicators];
}
can set indicator color as -
webView.scrollView.indicatorStyle = UIScrollViewIndicatorStyleWhite;

UIWebView inside UIScrollView and scrolling to the selected field in the web view

I have got a UIWebView, surrounded by the other elements, inside my UIScrollView. When any html field on the webView is selected it is not scrolled to it because scrolling of webView is disabled.
How can i scroll main UIScrollView to that field?
scrollView.scrollEnabled = YES;
Also, making sure if your scrollview set to cliptobounds = NO;
also, bring the webview to front if needed, maybe the scrollview is in clearcolor and stays in the back of the webview or vice versa.

User Interaction enabled No Only to the parent

I have one scroll view (UserInteractionEnabled = No) with one image view as its subview.
I am assigning tap gesture to imageview but it is not working even if imageview is UserInteractionEnabled because Its parent (ScrollView) is not.
How can I resolve this conflict.
There is no reason to disable user interaction on a scroll view. If you want to block the scrolling, disable it using the scrollEnabled property.
Don't set scroll view (UserInteractionEnabled = No) because it will set to all its subViews.
hope it will work.

Resources