-
Notifications
You must be signed in to change notification settings - Fork 947
/
Copy pathMDCPageControl.h
153 lines (108 loc) · 4.97 KB
/
MDCPageControl.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
// Copyright 2015-present the Material Components for iOS authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#import <UIKit/UIKit.h>
API_DEPRECATED_BEGIN("🤖👀 Use a branded UIPageControl instead. "
"See go/material-ios-branding for more info. "
"This has go/material-ios-migrations#scriptable-potential 🤖👀.",
ios(12, 12))
/**
A Material page control.
This control is designed to be a drop-in replacement for UIPageControl, but adhering to the
Material Design specifications for animation and layout.
The UIControlEventValueChanged control event is sent when the user changes the current page.
### UIScrollViewDelegate
In order for the Page Control to respond correctly to scroll events set the scrollView.delegate to
your pageControl:
scrollView.delegate = pageControl;
or forward the UIScrollViewDelegate methods:
@c scrollViewDidScroll:
@c scrollViewDidEndDecelerating:
@c scrollViewDidEndScrollingAnimation:
*/
@interface MDCPageControl : UIControl <UIScrollViewDelegate>
#pragma mark Managing the page
/**
The number of page indicators in the control.
Negative values are clamped to 0.
The default value is 0.
*/
@property(nonatomic) NSInteger numberOfPages;
/**
The current page indicator of the control.
See setCurrentPage:animated: for animated version.
Values outside the possible range are clamped within [0, numberOfPages-1].
The default value is 0.
*/
@property(nonatomic) NSInteger currentPage;
/**
Sets the current page indicator of the control.
@param currentPage Index of the desired page indicator. Values outside the possible range are
clamped within [0, numberOfPages-1].
@param animated YES the change will be animated; otherwise, NO.
*/
- (void)setCurrentPage:(NSInteger)currentPage animated:(BOOL)animated;
/**
A Boolean value that controls whether the page control is hidden when there is only one page.
The default value is NO.
*/
@property(nonatomic) BOOL hidesForSinglePage;
#pragma mark Configuring the page colors
/** The color of the non-current page indicators. */
@property(nonatomic, strong, nullable) UIColor *pageIndicatorTintColor UI_APPEARANCE_SELECTOR;
/** The color of the current page indicator. */
@property(nonatomic, strong, nullable)
UIColor *currentPageIndicatorTintColor UI_APPEARANCE_SELECTOR;
#pragma mark Configuring the page behavior
/**
A Boolean value that controls when the current page is displayed.
If enabled, user interactions that cause the current page to change will not be visually
reflected until -updateCurrentPageDisplay is called.
The default value is NO.
*/
@property(nonatomic) BOOL defersCurrentPageDisplay;
/**
When this value is set to YES, the indicators will ascend from right to left in an RTL environment.
@note In general, the MDCPageControl's UIScrollViewDelegate forwarding methods make assumptions
about the originating scrollview's page number based off its contentOffset. When this property is
set to YES in an RTL environment, a leftmost content offset will be considered the last page in the
scrollview, as opposed to the first.
The default value is NO.
*/
@property(nonatomic) BOOL respectsUserInterfaceLayoutDirection;
/**
Updates the page indicator to the current page.
This method is ignored if defersCurrentPageDisplay is NO.
*/
- (void)updateCurrentPageDisplay;
#pragma mark Resizing the control
/**
Returns the size required to accommodate the given number of pages.
@param pageCount The number of pages for which an estimated size should be returned.
*/
+ (CGSize)sizeForNumberOfPages:(NSInteger)pageCount;
#pragma mark UIScrollView interface
/** The owner must call this to inform the control that scrolling has occurred. */
- (void)scrollViewDidScroll:(nonnull UIScrollView *)scrollView;
/** The owner must call this when the scrollView has ended its deleration. */
- (void)scrollViewDidEndDecelerating:(nonnull UIScrollView *)scrollView;
/** The owner must call this when the scrollView has ended its scrolling animation. */
- (void)scrollViewDidEndScrollingAnimation:(nonnull UIScrollView *)scrollView;
/**
A block that is invoked when the @c MDCPageControl receives a call to @c
traitCollectionDidChange:. The block is called after the call to the superclass.
*/
@property(nonatomic, copy, nullable) void (^traitCollectionDidChangeBlock)
(MDCPageControl *_Nonnull pageControl, UITraitCollection *_Nullable previousTraitCollection);
@end
API_DEPRECATED_END