Using custom card (with embedded view + autolayout) freezes unless CardCellMargins left/right not set to 0
- Dominant language
- Swift
- Stars
- 2.5k
- Forks
- 221
- PR merge metrics
- No merged PRs in 30d
Description
First off, I want to say that this library is fantastic!
On to the problem:
I am using a stack of custom cards, one of which simply has a chart view embedded inside (taken from the iOS Charts library). However, using this card will cause the app to freeze unless I set the left and right margins to nonzero in the CardsViewController, e.g. with the following application:
```
let theme = CardPartsMintTheme()
theme.cardCellMargins = UIEdgeInsets(top: 100, left: 15, bottom: 100, right: 15)
theme.cardsViewContentInsetTop = 15
theme.cardsLineSpacing = 15
theme.apply()
```
However, doing so means that the cards cannot hug the edge of the screen. As mentioned previously, setting the insets to default (0 for left and right) causes the app to freeze.
See snippet for my custom card below, which has a chart embedded inside:
```
public class PAChartCardPartView : UIView, CardPartView {
var chart:CombinedChartView?
public init() {
super.init(frame: CGRect.zero)
self.chart = CombinedChartView(frame: CGRect.zero)
self.chart?.translatesAutoresizingMaskIntoConstraints = false
self.view.addSubview(self.chart!)
self.chart?.topAnchor.constraint(equalTo: self.view.topAnchor, constant: 0).isActive = true
self.chart?.bottomAnchor.constraint(equalTo: (self.view.bottomAnchor), constant: 0).isActive = true
self.chart?.leadingAnchor.constraint(equalTo: (self.view.leadingAnchor), constant: 0).isActive = true
self.chart?.trailingAnchor.constraint(equalTo: (self.view.trailingAnchor), constant: 0).isActive = true
}
required public init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
```
Is it possible to use this card without having to use nonzero left and right insets? Any help or insight would be greatly appreciated. Thanks!
Contributor guide
Assessment
This issue has not been assessed yet.