I've got a use case where those indicators disturb the user interaction. Can I subclass and override a method or do something similar to remove the scroll indicators from the scroll view?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Set the showsHorizontalScrollIndicator
and showsVerticalScrollIndicator
properties of the UIScrollView
to NO
.
[tableView setShowsHorizontalScrollIndicator:NO];
[tableView setShowsVerticalScrollIndicator:NO];
Documentation - UIScrollView
回答2:
//For UITableView - Objective-C
tbl.showsHorizontalScrollIndicator = NO;
tbl.showsVerticalScrollIndicator = NO;
//For UITableView - SWIFT 3.0
tbl.showsHorizontalScrollIndicator = false
tbl.showsVerticalScrollIndicator = false
//For UIScrollView - Objective-C
scrl.showsHorizontalScrollIndicator = NO;
scrl.showsVerticalScrollIndicator = NO;
//For UIScrollView - SWIFT
scrl.showsHorizontalScrollIndicator = false
scrl.showsVerticalScrollIndicator = false
Change from XIB or storyboard
回答3:
For those looking to do this in Swift.
self.tableView.showsHorizontalScrollIndicator = false
self.tableView.showsVerticalScrollIndicator = false
回答4:
For UIScrollView in Swift
scrollView?.showsHorizontalScrollIndicator = false
scrollView?.showsVerticalScrollIndicator = false
回答5:
These are your UITableView
scrolling properties:
[YourTableView setShowsHorizontalScrollIndicator:NO];
[YourTableView setShowsVerticalScrollIndicator:NO];
These are your UIScrollView
scrolling properties:
[YourScroll setShowsHorizontalScrollIndicator:NO];
[YourScroll setShowsVerticalScrollIndicator:NO];
回答6:
Swift 3 extension for UIScrollView and UITableView:
import Foundation
extension UIScrollView {
func hideIndicators() {
showsHorizontalScrollIndicator = false
showsVerticalScrollIndicator = false
}
}