基于 UICollectionView 设计的分段控件,主要用于横向或纵向的菜单视图。
let control = XZSegmentedControl.init(frame: CGRect(x: 0, y: 0, width: 375, height: 50), direction: .horizontal)
self.view.addSubview(control)
control.titles = ["标题一", "标题二"]
control.titleColor = .black
control.selectedTitleColor = .red
control.addTarget(self, action: #selector(segmentedControlValueChanged(_:)), for: .valueChanged)
To run the example project, clone the repo, and run pod install
from the Pods directory first.
iOS 11.0, Xcode 14.0
XZSegmentedControl is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'XZSegmentedControl'
Xezun, [email protected]
XZSegmentedControl is available under the MIT license. See the LICENSE file for more info.