A segment menu with line animation
- Swift 5
- iOS 8.0+
- XCode 10.2
class ViewController: UIViewController, VGSegmentDelegate{
override func viewDidLoad() {
super.viewDidLoad()
let rect = CGRect(x: 0, y: 250, width: view.frame.width, height: 45)
let titles = ["One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten"]
let segment = VGSegment(frame: rect, titles: titles)
segment.delegate = self
view.addSubview(segment)
var configuration: VGSegmentConfiguration {
let configura = VGSegmentConfiguration()
// TODO: configuration segment
return configura
}
segment.configuration = configuration
}
func didSelectAtIndex(_ index: Int) {
print("selectIndex:", index)
}
}
-
Download VGSegment. Move to your project.
-
Cocoapods
platform :ios, ‘8.0’
use_frameworks!
pod "VGSegment"
- Carthage
github "VeinGuo/VGSegment" ~> 1.0.1
- 1.0 Release (05/28/2017)
- 1.0.1 Release (05/31/2017)
- 1.0.2 fix horizontal and vertical autolayout