mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-02-02 20:16:54 +01:00
Fix section header separator antialiasing issues. Issue #1226
This commit is contained in:
parent
3629108b09
commit
18bee355e0
@ -50,11 +50,13 @@ class MasterFeedTableViewSectionHeader: UITableViewHeaderFooterView {
|
|||||||
|
|
||||||
var disclosureExpanded = false {
|
var disclosureExpanded = false {
|
||||||
didSet {
|
didSet {
|
||||||
updateDisclosureImage()
|
updateExpandedState()
|
||||||
updateUnreadCountView()
|
updateUnreadCountView()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var isLastSection = false
|
||||||
|
|
||||||
private let titleView: UILabel = {
|
private let titleView: UILabel = {
|
||||||
let label = NonIntrinsicLabel()
|
let label = NonIntrinsicLabel()
|
||||||
label.numberOfLines = 0
|
label.numberOfLines = 0
|
||||||
@ -126,21 +128,30 @@ private extension MasterFeedTableViewSectionHeader {
|
|||||||
func commonInit() {
|
func commonInit() {
|
||||||
addSubviewAtInit(unreadCountView)
|
addSubviewAtInit(unreadCountView)
|
||||||
addSubviewAtInit(titleView)
|
addSubviewAtInit(titleView)
|
||||||
updateDisclosureImage()
|
updateExpandedState()
|
||||||
addSubviewAtInit(disclosureView)
|
addSubviewAtInit(disclosureView)
|
||||||
addBackgroundView()
|
addBackgroundView()
|
||||||
addSubviewAtInit(topSeparatorView)
|
addSubviewAtInit(topSeparatorView)
|
||||||
addSubviewAtInit(bottomSeparatorView)
|
addSubviewAtInit(bottomSeparatorView)
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateDisclosureImage() {
|
func updateExpandedState() {
|
||||||
UIView.animate(withDuration: 0.3) {
|
if !isLastSection && self.disclosureExpanded {
|
||||||
if self.disclosureExpanded {
|
self.bottomSeparatorView.isHidden = false
|
||||||
self.disclosureView.transform = CGAffineTransform(rotationAngle: 1.570796)
|
|
||||||
} else {
|
|
||||||
self.disclosureView.transform = CGAffineTransform(rotationAngle: 0)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
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() {
|
func updateUnreadCountView() {
|
||||||
@ -161,9 +172,9 @@ private extension MasterFeedTableViewSectionHeader {
|
|||||||
unreadCountView.setFrameIfNotEqual(layout.unreadCountRect)
|
unreadCountView.setFrameIfNotEqual(layout.unreadCountRect)
|
||||||
disclosureView.setFrameIfNotEqual(layout.disclosureButtonRect)
|
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)
|
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)
|
bottomSeparatorView.setFrameIfNotEqual(bottom)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,6 +175,12 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
|
|||||||
headerView.tag = section
|
headerView.tag = section
|
||||||
headerView.disclosureExpanded = sectionNode.isExpanded
|
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(_:)))
|
let tap = UITapGestureRecognizer(target: self, action:#selector(self.toggleSectionHeader(_:)))
|
||||||
headerView.addGestureRecognizer(tap)
|
headerView.addGestureRecognizer(tap)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user