Skip to content

Commit

Permalink
Merge branch 'jrmsklar/use-attributed-strings' into jrmsklar/add-labe…
Browse files Browse the repository at this point in the history
…l-alignment
  • Loading branch information
jrmsklar committed Aug 4, 2017
2 parents 00d8b77 + deaf31d commit c9d04b3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion YSSegmentedControl/Demo/TableViewController.swift
Expand Up @@ -34,7 +34,7 @@ class TableViewController: UITableViewController {
segmented.delegate = self

var appearance = segmented.appearance
appearance?.textAttributes = [NSFontAttributeName: UIFont.systemFont(ofSize: 16), NSForegroundColorAttributeName: UIColor.gray]
appearance?.unselectedTextAttributes = [NSFontAttributeName: UIFont.systemFont(ofSize: 16), NSForegroundColorAttributeName: UIColor.gray]
appearance?.selectedTextAttributes = [NSFontAttributeName: UIFont.boldSystemFont(ofSize: 16), NSForegroundColorAttributeName: UIColor.black]
segmented.appearance = appearance

Expand Down
Expand Up @@ -14,7 +14,7 @@ public struct YSSegmentedControlAppearance {
public var backgroundColor: UIColor
public var selectedBackgroundColor: UIColor

public var textAttributes: [String : Any]
public var unselectedTextAttributes: [String : Any]
public var selectedTextAttributes: [String : Any]

public var bottomLineColor: UIColor
Expand Down Expand Up @@ -81,7 +81,7 @@ class YSSegmentedControlItem: UIControl {


commonInit()
label.attributedText = NSAttributedString(string: text, attributes: appearance.textAttributes)
label.attributedText = NSAttributedString(string: text, attributes: appearance.unselectedTextAttributes)
}

required init?(coder aDecoder: NSCoder) {
Expand Down Expand Up @@ -320,7 +320,7 @@ public class YSSegmentedControl: UIView {
appearance = YSSegmentedControlAppearance(
backgroundColor: .clear,
selectedBackgroundColor: .clear,
textAttributes: [:],
unselectedTextAttributes: [:],
selectedTextAttributes: [:],
bottomLineColor: .black,
selectorColor: .black,
Expand All @@ -342,7 +342,7 @@ public class YSSegmentedControl: UIView {
item.updateLabelAttributes(appearance.selectedTextAttributes)
item.backgroundColor = appearance.selectedBackgroundColor
} else {
item.updateLabelAttributes(appearance.textAttributes)
item.updateLabelAttributes(appearance.unselectedTextAttributes)
item.backgroundColor = appearance.backgroundColor
}
}
Expand Down

0 comments on commit c9d04b3

Please sign in to comment.