When I Added rightAnchor constraint, constant= 20 did not apply. In leftAnchor is ok
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)])
}
Can someone help me?