-
Notifications
You must be signed in to change notification settings - Fork 0
/
UISegmentControlExtention.swift
28 lines (23 loc) · 1.5 KB
/
UISegmentControlExtention.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//
// UISegmentControlExtention.swift
// Copyrobo
//
// Created by imac on 10/16/17.
// Copyright © 2017 CopyRobo. All rights reserved.
//
@objc
extension UISegmentedControl {
func customizeAppearance() {
setTitleTextAttributes([NSAttributedStringKey.font:UIFont(name:TRFontDefine.kTextFontOpensanSemiBold, size:12.0)!,NSAttributedStringKey.foregroundColor:UIColor.init(hexString: TRColorDefine.kColor17)], for:.normal)
setTitleTextAttributes([NSAttributedStringKey.font:UIFont(name:TRFontDefine.kTextFontOpensanSemiBold, size:12.0)!,NSAttributedStringKey.foregroundColor:UIColor.init(hexString: TRColorDefine.kColorPrivatePrimary)], for:.selected)
setDividerImage(UIImage().colored(with: .clear, size: CGSize(width: 1, height: self.frame.height)), forLeftSegmentState: .normal, rightSegmentState: .normal, barMetrics: .default)
setBackgroundImage(UIImage().colored(with: .clear, size: CGSize(width: 1, height: self.frame.height)), for: .normal, barMetrics: .default)
setBackgroundImage(UIImage().colored(with: .clear, size: CGSize(width: 1,height:self.frame.height)), for: .selected, barMetrics: .default);
for borderview in subviews {
let upperBorder: CALayer = CALayer()
upperBorder.backgroundColor = UIColor.clear.cgColor
upperBorder.frame = CGRect(x: 0, y: borderview.frame.size.height, width: borderview.frame.size.width, height: 0)
borderview.layer.addSublayer(upperBorder)
}
}
}