Fix section header separator antialiasing issues. Issue #1226

This commit is contained in:
Maurice Parker 2019-11-01 11:40:52 -05:00
parent 3629108b09
commit 18bee355e0
2 changed files with 28 additions and 11 deletions

View File

@ -50,11 +50,13 @@ class MasterFeedTableViewSectionHeader: UITableViewHeaderFooterView {
var disclosureExpanded = false {
didSet {
updateDisclosureImage()
updateExpandedState()
updateUnreadCountView()
}
}
var isLastSection = false
private let titleView: UILabel = {
let label = NonIntrinsicLabel()
label.numberOfLines = 0
@ -126,21 +128,30 @@ private extension MasterFeedTableViewSectionHeader {
func commonInit() {
addSubviewAtInit(unreadCountView)
addSubviewAtInit(titleView)
updateDisclosureImage()
updateExpandedState()
addSubviewAtInit(disclosureView)
addBackgroundView()
addSubviewAtInit(topSeparatorView)
addSubviewAtInit(bottomSeparatorView)
}
func updateDisclosureImage() {
UIView.animate(withDuration: 0.3) {
if self.disclosureExpanded {
self.disclosureView.transform = CGAffineTransform(rotationAngle: 1.570796)
} else {
self.disclosureView.transform = CGAffineTransform(rotationAngle: 0)
}
func updateExpandedState() {
if !isLastSection && self.disclosureExpanded {
self.bottomSeparatorView.isHidden = false
}
UIView.animate(
withDuration: 0.3,
animations: {
if self.disclosureExpanded {
self.disclosureView.transform = CGAffineTransform(rotationAngle: 1.570796)
} else {
self.disclosureView.transform = CGAffineTransform(rotationAngle: 0)
}
}, completion: { _ in
if !self.isLastSection && !self.disclosureExpanded {
self.bottomSeparatorView.isHidden = true
}
})
}
func updateUnreadCountView() {
@ -161,9 +172,9 @@ private extension MasterFeedTableViewSectionHeader {
unreadCountView.setFrameIfNotEqual(layout.unreadCountRect)
disclosureView.setFrameIfNotEqual(layout.disclosureButtonRect)
let top = CGRect(x: safeAreaInsets.left, y: 0, width: frame.width - safeAreaInsets.right - safeAreaInsets.left, height: 0.5)
let top = CGRect(x: safeAreaInsets.left, y: 0, width: frame.width - safeAreaInsets.right - safeAreaInsets.left, height: 0.25)
topSeparatorView.setFrameIfNotEqual(top)
let bottom = CGRect(x: safeAreaInsets.left, y: frame.height - 0.5, width: frame.width - safeAreaInsets.right - safeAreaInsets.left, height: 0.5)
let bottom = CGRect(x: safeAreaInsets.left, y: frame.height - 0.25, width: frame.width - safeAreaInsets.right - safeAreaInsets.left, height: 0.25)
bottomSeparatorView.setFrameIfNotEqual(bottom)
}

View File

@ -174,6 +174,12 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
headerView.tag = section
headerView.disclosureExpanded = sectionNode.isExpanded
if section == tableView.numberOfSections - 1 {
headerView.isLastSection = true
} else {
headerView.isLastSection = false
}
let tap = UITapGestureRecognizer(target: self, action:#selector(self.toggleSectionHeader(_:)))
headerView.addGestureRecognizer(tap)