Comments (7)
This could certainly be fixed in a custom StackViewCell
subclass. Mostly curious if this is something that could be included in the base implementation without needed to implement a custom cell class.
from aloestackview.
Playing around with this some more, since the separator view and constraints are all private, fixing this in a custom cell subclass would require a bunch of messy code and workarounds.
from aloestackview.
I was able to get this sorted by responding to safeAreaInsetsDidChange
in a custom AloeStackView
subclass and adjusting each row's separator and row inset to adjust for the new safeAreaInsets
.
Since this is likely a common issue in popovers on iOS 13, it would be awesome if this was built into the base class. Any feedback on this would be great and I'd be happy to work on a fix.
from aloestackview.
hey @colinhumber thanks for reporting this! We'll take a look at this - if you could share some of your code for a fix, we'll get back to you with a proposed solution for this issue.
from aloestackview.
Awesome!
This fixes it if the fix is directly within StackViewCell
.
// this could be removed, since insetsLayoutMarginsFromSafeArea = false is the default
if #available(iOS 11.0, *) {
insetsLayoutMarginsFromSafeArea = true
}
private func setUpSeparatorViewConstraints() {
if #available(iOS 11.0, *) {
separatorTopConstraint = separatorView.topAnchor.constraint(equalTo: safeAreaLayoutGuide.topAnchor)
separatorBottomConstraint = separatorView.bottomAnchor.constraint(equalTo: safeAreaLayoutGuide.bottomAnchor)
separatorLeadingConstraint = separatorView.leadingAnchor.constraint(equalTo: safeAreaLayoutGuide.leadingAnchor)
separatorTrailingConstraint = separatorView.trailingAnchor.constraint(equalTo: safeAreaLayoutGuide.trailingAnchor)
} else {
separatorTopConstraint = separatorView.topAnchor.constraint(equalTo: topAnchor)
separatorBottomConstraint = separatorView.bottomAnchor.constraint(equalTo: bottomAnchor)
separatorLeadingConstraint = separatorView.leadingAnchor.constraint(equalTo: leadingAnchor)
separatorTrailingConstraint = separatorView.trailingAnchor.constraint(equalTo: trailingAnchor)
}
}
Since the separator constraints are private, I wasn't able to fix it in a StackViewCell
subclass, so I created an AloeStackView
subclass to handle it instead. This fix assumes all rows are added upfront before any safeAreaInsets would change.
class SafeAreaAdjustingStackView: AloeStackView {
@available(iOS 11.0, *)
public override func safeAreaInsetsDidChange() {
super.safeAreaInsetsDidChange()
getAllRows().forEach {
guard let cell = $0.superview as? StackViewCell else { return }
// adjust separator inset for the new safe area
let currentSeparatorInset = cell.separatorInset
let adjustedSeparatorInset = UIEdgeInsets(top: currentSeparatorInset.top,
left: currentSeparatorInset.left + safeAreaInsets.left,
bottom: currentSeparatorInset.bottom,
right: currentSeparatorInset.right + safeAreaInsets.right)
setSeparatorInset(forRow: $0, inset: adjustedSeparatorInset)
// adjust row inset for the new safe area
let currentRowInset = cell.rowInset
let adjustedRowInset = UIEdgeInsets(top: currentRowInset.top,
left: currentRowInset.left + safeAreaInsets.left,
bottom: currentRowInset.bottom,
right: currentRowInset.right + safeAreaInsets.right)
setInset(forRow: $0, inset: adjustedRowInset)
}
}
}
from aloestackview.
@apang42 Hey! Just wanted to follow up and see if there had been any internal discussions about this. Thanks!
from aloestackview.
Any updates on this fix?
from aloestackview.
Related Issues (20)
- AloeStackViewController to support child UIViewControllers as a row HOT 3
- Improved touch and tap handling of cells HOT 1
- Swift 5 support HOT 3
- s.swift_version = '5.0' HOT 1
- Carthage build error with Xcode 11.0 beta 4 HOT 2
- Embedding TableView as row HOT 1
- [Feature suggestion] Paging
- [Feature Suggestion] willDisplay/endDisplay
- [Question] Access to the cell HOT 2
- No way to get the RowCount HOT 1
- RTL support on horizontal stack?
- Get access to UIStackview HOT 1
- Cannot build with `swift build`
- [Feature Suggestion] Reorder cells
- Scrolling always on?
- [question] Add stackView to container (with Storyboard)
- Problem when build on simulator, Xcode Version 12.0.1 (12A7300)
- SPM support?
- Is this library maintained? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aloestackview.