1
UISegmetedControl
에서 선택한 색을 제거하고 싶습니다. 나는 tintColor
이 이것을 할 수 있지만 그것도 그걸로 글꼴 색상을 제거 알아요. 또한 kCTForegroundColorAttributeName
을 사용하면 둘 다 제거됩니다.틴트 색을 제거하지만 글꼴 색 유지 UISegmentedControl
사이드 노트 UIView
을 만들어 선택한 세그먼트 위에 배치하여 선택한 상태를 표시합니다. 나는 이것이 더 좋아 보일 것이라고 생각했다. 분기하고 내 자신의 사용자 지정 컨트롤을 만들려고합니다.
public let topLine = UIView()
override func awakeFromNib() {
super.awakeFromNib()
self.removeBorders()
setFont()
addTopLine()
}
func setFont() {
let font = UIFont(name: FontTypes.avenirNextUltraLight, size: 22.0)!
let textColor = UIColor.MyColors.flatWhite
let attribute = [kCTFontAttributeName:font]
self.setTitleTextAttributes(attribute, for: .normal)
}
func addTopLine() {
topLine.backgroundColor = UIColor.MyColors.flatWhite
let frame = CGRect(x: 7,
y: -5,
width: Int(self.frame.size.width)/2,
height: 2)
topLine.frame = frame
self.addSubview(topLine)
}
struct FontTypes {
static let avenirNextRegular = "AvenirNext-Regular"
static let avenirLight = "Avenir-Light"
static let avenirNextUltraLight = "AvenirNext-UltraLight"
}