【发布时间】:2018-07-11 15:19:05
【问题描述】:
我尝试在导航栏中附加 UISegmentedControl,但出现问题:
分段控制:
func segmentControl() -> UIView {
let newUIView = UIView()
newUIView.backgroundColor = UIColor.clear
newUIView.layer.cornerRadius = 15.0
let items = ["list", "map"]
let customSC = UISegmentedControl(items: items)
customSC.layer.cornerRadius = 15.0
customSC.layer.borderWidth = 1
customSC.layer.borderColor = UIColor.green.cgColor
customSC.clipsToBounds = true
customSC.tintColor = UIColor.green
let font = UIFont.systemFont(ofSize: 16)
customSC.setTitleTextAttributes([NSAttributedStringKey.font: font],
for: .normal)
newUIView.addSubview(customSC)
return newUIView
}
我尝试附上:
SomeTab.navigationItem.titleView = segmentControl()
它应该看起来像:
【问题讨论】:
-
有什么问题??
-
段控制不显示。
标签: ios swift uikit uisegmentedcontrol