Skip to content
Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
45 lines (39 sloc) 1.08 KB
//
// UISegmentedControlExtensions.swift
// SwifterSwift
//
// Created by Omar Albeik on 9/28/16.
// Copyright © 2016 SwifterSwift
//
#if canImport(UIKit) && !os(watchOS)
import UIKit
// MARK: - Properties
public extension UISegmentedControl {
/// SwifterSwift: Segments titles.
public var segmentTitles: [String] {
get {
let range = 0..<numberOfSegments
return range.compactMap { titleForSegment(at: $0) }
}
set {
removeAllSegments()
for (index, title) in newValue.enumerated() {
insertSegment(withTitle: title, at: index, animated: false)
}
}
}
/// SwifterSwift: Segments images.
public var segmentImages: [UIImage] {
get {
let range = 0..<numberOfSegments
return range.compactMap { imageForSegment(at: $0) }
}
set {
removeAllSegments()
for (index, image) in newValue.enumerated() {
insertSegment(with: image, at: index, animated: false)
}
}
}
}
#endif
You can’t perform that action at this time.