I want to put an Image on my Crossmobile application using the code bellow
img=new UIImageView(new CGRect(15, 15, 66, 66));
img.frame().setSize(new CGSize(66,66));
img.setAutoresizingMask(2);
img.sizeThatFits(new CGSize(33, 33));
When the image appears on the app,the size is much bigger than the size i have put in the code. I found the UIImage on the https://developer.apple.com/documentation/uikit/uiimage.
How could i fix the size of the image, to fit on my imgview square size?
Some notes:
you have already set the size of the UIImageView. You don't need to define it when you construct it and then redefine the frame.
the autoresizingMask is used when the parent UIView changes size, it doesn't define the fitting properties of the current UIView
the sizeThatFits selector just returns the optimum size, it doesn't change the image size.
What you actually need is to set the contentMode, with its modes defined here. I suspect you need the
UIViewContentMode.ScaleAspectFit
mode?