I'm using an SF symbol image into a UIImageView. I have given the constrains as well. What I have seen running the same code into different simulators actually increases the width of the image but I want to give fixed width into different iOS simulators.
Here is the code for the image:
let rightImageView: UIImageView = {
let rightImageView = UIImageView()
rightImageView.image = UIImage(systemName: "arrow.right")
rightImageView.translatesAutoresizingMaskIntoConstraints = false
rightImageView.tintColor = .purple
return rightImageView
}()
Here is the constrains for it and other properties:
private func setUpUI() {
view.addSubview(stackview)
stackview.dm_addArrangedSubviews(titleLable)
stackview.dm_addArrangedSubviews(viewAllLable)
stackview.dm_addArrangedSubviews(rightImageView)
view.addSubview(collectionView)
let safeArea = view.safeAreaLayoutGuide
NSLayoutConstraint.activate([
stackview.leadingAnchor.constraint(equalTo: view.leadingAnchor),
stackview.trailingAnchor.constraint(equalTo: view.trailingAnchor),
stackview.topAnchor.constraint(equalTo: view.topAnchor),
collectionView.topAnchor.constraint(equalTo: stackview.bottomAnchor),
collectionView.leadingAnchor.constraint(equalTo: safeArea.leadingAnchor),
collectionView.trailingAnchor.constraint(equalTo: safeArea.trailingAnchor),
collectionView.heightAnchor.constraint(equalToConstant: view.frame.width/2)
])
}
Here is the screenshot in iPhone 15 Pro Max:

Here is the screenshot in iPhone 15 simulator:

Here is the screenshot on different mode, the right arrow image width is set properly:

As you can see, the width of the rightImageView property is increased. How can I give fixed width for different device?




dm_addArrangedSubviews), and all of which have required follow up questions. Please take some time to review How to Ask to make it easier to get help.