Est-il possible de masquer les indicateurs de défilement dans UIScrollView?
-
03-07-2019 - |
Question
J'ai un cas d'utilisation où ces indicateurs perturbent l'interaction de l'utilisateur. Puis-je sous-classer et remplacer une méthode ou faire quelque chose de similaire pour supprimer les indicateurs de défilement de la vue défilement?
La solution
Définissez les propriétés showsHorizontalScrollIndicator
et showsVerticalScrollIndicator
des propriétés UIScrollView
sur NO
.
[tableView setShowsHorizontalScrollIndicator:NO];
[tableView setShowsVerticalScrollIndicator:NO];
Autres conseils
// Pour UITableView - Objective-C
tbl.showsHorizontalScrollIndicator = NO;
tbl.showsVerticalScrollIndicator = NO;
// Pour UITableView - SWIFT 3.0
tbl.showsHorizontalScrollIndicator = false
tbl.showsVerticalScrollIndicator = false
// Pour UIScrollView - Objective-C
scrl.showsHorizontalScrollIndicator = NO;
scrl.showsVerticalScrollIndicator = NO;
// Pour UIScrollView - SWIFT
scrl.showsHorizontalScrollIndicator = false
scrl.showsVerticalScrollIndicator = false
Modification de XIB ou du storyboard
Pour ceux qui cherchent à le faire dans Swift.
self.tableView.showsHorizontalScrollIndicator = false
self.tableView.showsVerticalScrollIndicator = false
Pour UIScrollView dans Swift
scrollView?.showsHorizontalScrollIndicator = false
scrollView?.showsVerticalScrollIndicator = false
Ce sont vos propriétés de défilement UITableView
:
[YourTableView setShowsHorizontalScrollIndicator:NO];
[YourTableView setShowsVerticalScrollIndicator:NO];
Ce sont vos propriétés de défilement UIScrollView
:
[YourScroll setShowsHorizontalScrollIndicator:NO];
[YourScroll setShowsVerticalScrollIndicator:NO];
Swift 3.0
extension pour UIScrollView
et UITableView
:
import Foundation
extension UIScrollView {
func hideIndicators() {
showsHorizontalScrollIndicator = false
showsVerticalScrollIndicator = false
}
}