ios 有没有办法在 UIScrollView 中隐藏滚动指示器?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/821818/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 15:53:00  来源:igfitidea点击:

Is there a way to hide the scroll indicators in a UIScrollView?

iosuiscrollview

提问by Thanks

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?

我有一个用例,这些指标会干扰用户交互。我可以子类化并覆盖方法或执行类似操作以从滚动视图中删除滚动指示器吗?

回答by retainCount

Set the showsHorizontalScrollIndicatorand showsVerticalScrollIndicatorproperties of the UIScrollViewto NO.

将 的showsHorizontalScrollIndicatorshowsVerticalScrollIndicator属性设置UIScrollViewNO

[tableView setShowsHorizontalScrollIndicator:NO];
[tableView setShowsVerticalScrollIndicator:NO];

Documentation - UIScrollView

文档 - UIScrollView

回答by Bhavesh Nayi

//For UITableView - Objective-C

//对于 UITableView - Objective-C

tbl.showsHorizontalScrollIndicator = NO;
tbl.showsVerticalScrollIndicator = NO;

//For UITableView - SWIFT 3.0

//对于 UITableView - SWIFT 3.0

tbl.showsHorizontalScrollIndicator = false
tbl.showsVerticalScrollIndicator = false

//For UIScrollView - Objective-C

//对于 UIScrollView - Objective-C

scrl.showsHorizontalScrollIndicator = NO;
scrl.showsVerticalScrollIndicator = NO;

//For UIScrollView - SWIFT

//对于UIScrollView - SWIFT

scrl.showsHorizontalScrollIndicator = false
scrl.showsVerticalScrollIndicator = false

Change from XIB or storyboard

从 XIB 或故事板更改

enter image description here

在此处输入图片说明

回答by davidrayowens

For those looking to do this in Swift.

对于那些希望在 Swift 中做到这一点的人。

self.tableView.showsHorizontalScrollIndicator = false
self.tableView.showsVerticalScrollIndicator = false

回答by mattyU

For UIScrollView in Swift

对于 Swift 中的 UIScrollView

scrollView?.showsHorizontalScrollIndicator = false
scrollView?.showsVerticalScrollIndicator = false

回答by Darshan Kunjadiya

These are your UITableViewscrolling properties:

这些是您的UITableView滚动属性:

[YourTableView setShowsHorizontalScrollIndicator:NO];
[YourTableView setShowsVerticalScrollIndicator:NO];

These are your UIScrollViewscrolling properties:

这些是您的UIScrollView滚动属性:

[YourScroll setShowsHorizontalScrollIndicator:NO];
[YourScroll setShowsVerticalScrollIndicator:NO];

回答by Roman Barzyczak

Swift 3.0extension for UIScrollViewand UITableView:

Swift 3.0UIScrollView和 的扩展名UITableView

import Foundation

extension UIScrollView {
    func hideIndicators() {
        showsHorizontalScrollIndicator = false
        showsVerticalScrollIndicator = false
    }
}