UIImage being stretched when copying from UIPasteboard - ios

I have a valid image with the right content size, however I have noticed when I try to paste this image to WhatsApp or through iMessage the image get's significantly stretched. I have looked at the image and it seams to be fine on UIImageview, but somehow it gets stretched in particular to outer controls.
Is there anyway to fix this issue?

When copying an image make sure to modify the imageView's mode. There are different modes, like Aspect Fit, Scale to fill and so on.
If let's say the image is 500x300 and your imageView's size is set to 350x230 and mode to Scale to fill, it will end up stretched. Try to fiddle around and see what works for you. Most of the times i choose Aspect Fit.
Try that out.
BTW. You can find it under inspection tab in design editor or set it programmatically if you choose so.

Related

scale type or contentMode of Image in UIButton is not working

I was trying to put an image in UIButton and the image would fill up the space keeping the aspect ratio intact. I was not able to apply the content mode. Please see the screenshot
I also tried from the code and it's not working as well
myButton.imageView?.contentMode = .scaleAspectFill
By changing the alignment, the image takes the whole space but it does not keep the aspect ratio and content mode does not work as well.
What's causing your problem is how small the image is. There are two things you can do. One option is to set the image you have now as the background image and then change the button's constraints to get the proportions right. You won't be able to have the button be the size you have it now, though, because the image will be all stretched out.
The other thing you could do is find a bigger or different image of that symbol (square.and.arrow), rather than using the one already loaded into Xcode.

Stretched Image With Correct Constraints

I've recently started a tug-of-war style game but in a single view application. I have a circular image over a resetScore button and all is well until I try to run the application. When I do so the image is out of the perfect circle form and stretched to a vertical oval. I have centered my image in the UIViewController but that has not worked. With one of the reset variations, I set the aspect ratio of the image to that of the background and then I set the image to the aspect of 1-1 and the image came out in the right proportions on the simulator but then I tried that with one of the other reset variations an it did not work like it had before. If anyone knew of a solution towards this that would be much appreciated.

UIViewContentMode options in Swift

I'm having a bit of trouble understanding and/or implementing images with a particular fill type into my project. The background is a UIImageView. Here is a screenshot of my app's "Profile" page
The image is pulled in from Facebook, using the Facebook graph. The image is a 720x720 square.
The image looks decent in the smaller circle, however the background version doesn't fill the way I would expect it to. Despite having tried all of the "ScaleAspect______" methods, the background looks as shown.
My understanding was that ScaleAspectFill would do what I want, which is the scale the image down until either X or Y is the size of the frame and then crop the remainder out. That's how it's shown on the Apple Docs.
I have added and removed clipsToBounds to the ImageView, neither of which made any changes.
The image I'm working with can be found here:
https://graph.facebook.com/10152976336695409/picture?width=640&height=640
downloaded
EDIT: Clarified that the background is a UIImageView type.

Scale to fit cuts image

I have an UIImageView with the image of a gradient with a thin line at the bottom. As the image isn't the same size as the imageview I want to scale it in some way. I don't care if I stretch the image but I would like the line at the bottom to be visible. Therefore I chose "Scale To Fill". But as you can see on the second screenshot the bottom line is not showing up in the simulator.
I thought that "Scale to fill" meant that the image got stretched so that all content is visible but that doesn't seem to be the case.
I highly appreciate your answers!
As the image isn't the same size as the imageview I want to scale it in some way. I don't care if I stretch the image
So use a resizable image (resizableImageWithCapInsets:). This is exactly what it is for.
but I would like the line at the bottom to be visible.
Well, there are some extra complications here, and you are not explaining how you are handling them. You have a UIImageView; it has a size. Perhaps it is bigger than the view we are seeing in the screen shot. Perhaps it is being overlapped by the text view that we see below it. In other words, it matters how this image view is being placed in the interface and sized.

iOS Some UIImageView being stretched

This seems like a silly question, but I have a UITableView and each row has a UIImageView with a dimension of 80x80. The actual content of the image is either 80x80 or 80x64. I recently added some new 80x64 images and the heights of those are being stretched whereas the old 80x64 images are not (they are simply centered within the 80x80 frame).
I vaguely remember setting some kine of xattr on my images a while back, but I can't seem to find what it was. Would this have something to do with my new images being stretched vertically?
You might want to look at the contentMode for your image view, specifically try UIViewContentModeScaleAspectFit. I notice this, especially, when I set image properties for UITableViewCell cells asynchronously. But if I have the routine that is setting the image to also set the contentMode, and all is well.

Resources