-
Notifications
You must be signed in to change notification settings - Fork 780
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
backgroundColor for AnimatableStackView not set by FillDesignable #461
Comments
I think that we shouldn't fix this issue.
|
@lastMove I think that's a valid point. There is obviously a reason why Apple decided to give
|
I agree with @lastMove, I would follow apple opinons on this. Since In a long term process, I would be in favor to remove that designable protocol since it doesn't add features but that's another discussion 😬 |
Prematurely closed. This bug (which is becoming a feature) is still under review. |
I agree with @lastMove too. UIStackView is like viewgroup in Android. It is a view container. |
One way to resolve this issue is to pin an other view and copy the attributes For instance for FillDesignable and CornerDesigable class AnimatableStackView ...
...
// MARK: - Fix background
func configureCornerRadius() {
configureBackgroundView()
}
func configureFillColor() {
configureBackgroundView()
}
func configureBackgroundView() {
backgroundView.translatesAutoresizingMaskIntoConstraints = false
backgroundView.predefinedColor = predefinedColor
backgroundView.fillColor = fillColor
backgroundView.cornerRadius = cornerRadius
backgroundView.cornerSides = cornerSides
if fillColor ?? predefinedColor?.color != nil {
insertSubview(backgroundView, at: 0)
backgroundView.pin(to: self)
} else {
backgroundView.removeFromSuperview()
}
}
private var backgroundView = AnimatableView()
}
private extension UIView {
func pin(to view: UIView) {
NSLayoutConstraint.activate([
leadingAnchor.constraint(equalTo: view.leadingAnchor),
trailingAnchor.constraint(equalTo: view.trailingAnchor),
topAnchor.constraint(equalTo: view.topAnchor),
bottomAnchor.constraint(equalTo: view.bottomAnchor)
])
}
} |
@phimage thanks for investigating that. I agree with @SD10 we probably keep the default behavior. We may add a comment to |
Yes I agree. Some doc and the issue could be closed. The default way to do in storyboard is to add a view then inside a stackview |
I think we should just remove the
I can submit a PR if you like |
Not only FillDesignable |
This is true, anything that relies on |
Issue
backgroundColor for
AnimatableStackView
not set byFillDesignable
protocol and remainsnil
Apparently
UIStackView
is a non-drawing view sodrawRect()
is never called and thebackgroundColor
is not applied.EDIT: This obviously affects setting the
opacity
as wellPossible Solutions
We can possibly solve this by:
CAShapeLayer
with the background color inlayoutSubviews()
UIView
with the background color inlayoutSubviews()
This is not my domain of expertise so I thought I would bounce some ideas off the rest of you.
The text was updated successfully, but these errors were encountered: