SkeletonView: SkeletonView does not update with AutoLayout
What did you do?
Tried to use isSkeletonable on a view laid out by auto-layout
What did you expect to happen?
The view would render in the auto-layout calculated position with shimmer
What happened instead?
The view did not show up
OR
If I set a background color, it shows up as background color, but no shimmer
Steps to reproduce the behavior
100% reproducible
let fakeText = UIView()
view.addSubview(fakeText)
fakeText.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint(item: fakeText, attribute: .leading, relatedBy: .equal, toItem: view, attribute: .leading, multiplier: 1, constant: CGFloat(16)).isActive = true
NSLayoutConstraint(item: fakeText, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: CGFloat(16)).isActive = true
NSLayoutConstraint(item: fakeText, attribute: .top, relatedBy: .equal, toItem: view, attribute: .top, multiplier: 1, constant: CGFloat(16)).isActive = true
// Trying to let autolayout determine the width the component does not render with a shimmer
// NSLayoutConstraint(item: fakeText, attribute: .width, relatedBy: .equal, toItem: view, attribute: .width, multiplier: 1, constant: -CGFloat(16)).isActive = true
// Setting the width statically it will render
NSLayoutConstraint(item: fakeText, attribute: .width, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: CGFloat(200)).isActive = true
// If I set a background color, the component will render in the expected position with red background in the width relationship case.
// This demonstrates it as not an auto-layout issue.
// In the static width case, setting background has no effect.
fakeText.backgroundColor = UIColor.red
fakeText.isSkeletonable = true
SkeletonView Environment
SkeletonView version: 1.4.2 Xcode version: 10.1 Swift version: 4.2
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 17 (1 by maintainers)
I am also facing this issue.
I’m having the same issue. Any result about it?
I putted inside DispatchQueue block code. It’s working.