Вы добавляете 20 + rightAnchor вашего суперпредставления. Должно быть -20
я добавил ограничение rightAnchor, константа 20 не применялась. В левом якорь в порядке
override init(frame: CGRect) {
super.init(frame: frame)
addSubview(collectionView)
collectionView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([collectionView.leftAnchor.constraint(equalTo: leftAnchor, constant: 20),
collectionView.topAnchor.constraint(equalTo: self.topAnchor),
collectionView.rightAnchor.constraint(equalTo: rightAnchor, constant: 20),
collectionView.heightAnchor.constraint(equalTo: self.heightAnchor)])
}
Кто-нибудь может мне помочь?