DQSegmentedControl
UISegmentedControl 的替代品,模仿了分段控制的样式
特性
- 支持文本
- 支持使用字体、颜色、字距、阴影等文本属性进行高级标题样式
- 支持上下两种选择指示器
- 与 ARC 和 iOS >= 8 兼容
待办事项
- 支持图片
安装
CocoaPods
安装 DQSegmentedControl 最简单的方式是通过 CocoaPods。
pod 'DQSegmentedControl'
使用方法
以下代码将创建一个具有默认外观的分段控制按钮。
let control = DQSegmentedControl(frame: CGRect(x: 0, y: 34, width: UIScreen.main.bounds.width, height: 60))
control.sectionTitles = ["大前天","前天", "昨天", "今天", "明天", "后天", "大后天"]
control.delegate = self
control.titleTextAttributes = [.font: UIFont.systemFont(ofSize: 16),.foregroundColor:UIColor.black]
control.selectedTitleTextAttributes = [.font: UIFont.boldSystemFont(ofSize: 16),.foregroundColor:UIColor.red]
control.selectionIndicatorHeight = 2
control.selectionIndicatorColor = UIColor.red
control.selectionIndicatorEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: -10, right: 0);
view.addSubview(control)
@HeshamMegid,本项目的开发在很大程度上参考了他的 HMSegmentedControl。
特别感谢许可证
DQSegmentedControl遵循MIT许可证的条款。请参阅LICENSE文件以获取完整详细信息。