Add animationDuration and numberOfLines of segmentTitleLabel to SegmentioOptions. Update README.md.
This commit is contained in:
parent
34cf755361
commit
2808a754eb
|
|
@ -114,8 +114,10 @@ SegmentioOptions(
|
|||
horizontalSeparatorOptions: SegmentioHorizontalSeparatorOptions,
|
||||
verticalSeparatorOptions: SegmentioVerticalSeparatorOptions,
|
||||
imageContentMode: UIViewContentMode.Center,
|
||||
labelTextNumberOfLines: 1,
|
||||
labelTextAlignment: NSTextAlignment.Center,
|
||||
segmentStates: SegmentioStates // tuple of SegmentioState (defaultState, selectState, highlightedState)
|
||||
segmentStates: SegmentioStates, // tuple of SegmentioState (defaultState, selectState, highlightedState)
|
||||
animationDuration: 0.1
|
||||
)
|
||||
```
|
||||
|
||||
|
|
@ -198,4 +200,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
THE SOFTWARE.
|
||||
|
|
|
|||
|
|
@ -267,6 +267,7 @@ class SegmentioCell: UICollectionViewCell {
|
|||
|
||||
if style.isWithText() {
|
||||
segmentTitleLabel?.textAlignment = options.labelTextAlignment
|
||||
segmentTitleLabel?.numberOfLines = options.labelTextNumberOfLines
|
||||
let defaultState = options.states.defaultState
|
||||
segmentTitleLabel?.textColor = defaultState.titleTextColor
|
||||
segmentTitleLabel?.font = defaultState.titleFont
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@ import QuartzCore
|
|||
|
||||
public typealias SegmentioSelectionCallback = ((_ segmentio: Segmentio, _ selectedSegmentioIndex: Int) -> Void)
|
||||
|
||||
private let animationDuration: CFTimeInterval = 0.3
|
||||
|
||||
open class Segmentio: UIView {
|
||||
|
||||
internal struct Points {
|
||||
|
|
@ -438,7 +436,7 @@ open class Segmentio: UIView {
|
|||
let animation = CABasicAnimation(keyPath: "path")
|
||||
animation.fromValue = shapeLayer.path
|
||||
animation.toValue = shapeLayerPath.cgPath
|
||||
animation.duration = animationDuration
|
||||
animation.duration = segmentioOptions.animationDuration
|
||||
CATransaction.setCompletionBlock() {
|
||||
self.isPerformingScrollAnimation = false
|
||||
self.isUserInteractionEnabled = true
|
||||
|
|
|
|||
|
|
@ -162,7 +162,9 @@ public struct SegmentioOptions {
|
|||
var indicatorOptions: SegmentioIndicatorOptions?
|
||||
var imageContentMode: UIViewContentMode
|
||||
var labelTextAlignment: NSTextAlignment
|
||||
var labelTextNumberOfLines: Int
|
||||
var states: SegmentioStates
|
||||
var animationDuration: CFTimeInterval
|
||||
|
||||
public init() {
|
||||
self.backgroundColor = .lightGray
|
||||
|
|
@ -176,15 +178,17 @@ public struct SegmentioOptions {
|
|||
|
||||
self.imageContentMode = .center
|
||||
self.labelTextAlignment = .center
|
||||
self.labelTextNumberOfLines = 0
|
||||
|
||||
self.states = SegmentioStates(
|
||||
defaultState: SegmentioState(),
|
||||
selectedState: SegmentioState(),
|
||||
highlightedState: SegmentioState()
|
||||
)
|
||||
self.animationDuration = 0.1
|
||||
}
|
||||
|
||||
public init(backgroundColor: UIColor, maxVisibleItems: Int, scrollEnabled: Bool, indicatorOptions: SegmentioIndicatorOptions?, horizontalSeparatorOptions: SegmentioHorizontalSeparatorOptions?, verticalSeparatorOptions: SegmentioVerticalSeparatorOptions?, imageContentMode: UIViewContentMode, labelTextAlignment: NSTextAlignment, segmentStates: SegmentioStates) {
|
||||
public init(backgroundColor: UIColor, maxVisibleItems: Int, scrollEnabled: Bool, indicatorOptions: SegmentioIndicatorOptions?, horizontalSeparatorOptions: SegmentioHorizontalSeparatorOptions?, verticalSeparatorOptions: SegmentioVerticalSeparatorOptions?, imageContentMode: UIViewContentMode, labelTextAlignment: NSTextAlignment, labelTextNumberOfLines: Int, segmentStates: SegmentioStates, animationDuration: CFTimeInterval) {
|
||||
self.backgroundColor = backgroundColor
|
||||
self.maxVisibleItems = maxVisibleItems
|
||||
self.scrollEnabled = scrollEnabled
|
||||
|
|
@ -193,7 +197,9 @@ public struct SegmentioOptions {
|
|||
self.verticalSeparatorOptions = verticalSeparatorOptions
|
||||
self.imageContentMode = imageContentMode
|
||||
self.labelTextAlignment = labelTextAlignment
|
||||
self.labelTextNumberOfLines = labelTextNumberOfLines
|
||||
self.states = segmentStates
|
||||
self.animationDuration = animationDuration
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue