I have added an icon to my assets to be used in an image view. However, When I put it in an image view the outer edges seem to be larger than the image itself. Is there any way I can fully fill the image. Even when I try scale to fill or aspect fill, fit options still there remains a margin in between.
In other words I want my circular image to be tangent to the image view rectangle
The example of what I am trying to do
Related
I feel like I'm going crazy. I set my UIImageView.contentMode = UIViewContentModeScaleAspectFill, but it is still stretching the image. (Not a clipping issue, it is stretching the image.)
It even shows it stretched in my Storyboard. I created an image of green and brown squares to test:
I added a UIImageView in my Storyboard. I added the image to that image view, and when I'm setting to Aspect FIT then it does what it is supposed to do (maintain aspect ratio and show the whole image allowing gaps as needed), but when I switch to Aspect FILL then it stretches the image. Here is an animated gif from my storyboard:
What the heck is going on? This is in a storyboard in a project that is a few years old. If I create a brand new project with a brand new storyboard, then this insanity doesn't happen.
Is there something in my underlying storyboard that is causing this bug?
Any help is appreciated. I feel like I'm taking crazy pills.
It's not stretching it. It's filling the area while keeping the aspect ratio. If it were stretching it, the horizontal white line in the middle would not be as tall as the vertical white lines are wide.
Set the content mode to "Scale To Fill" to see what it would look like if it were getting stretched (like this):
Note the difference in line thickness of the middle white line, as opposed to when it's set to Aspect Fill:
If you turn off Clip to Bounds on the image view, then you can see how the image is getting cropped when set to Aspect Fill:
If you want to show the full image at the full width while keeping the aspect ratio, you'll have to increase that cell's height to accommodate the height of the image.
I want to thank anyone of you who is contributing to this community, and i which to find a solution to the issue that is presented below:
this is a capture of my xcode project Main Storyboard:
it contains a background image view with a grid picture and a small image view over it with a cercle picture.the content mode is the same for both views is aspect fit.
what i am trying to achieve here is to get the same combination between the two images, as in this picture, on all devices.
so basically sticking the cercle image to the background image (the grid image) so that if the background image dimensions change on another device the dimensions of the cercle image change the same way to keep the same view as in this picture.
I grabbed your image and clipped out the circle.
The "grid" actual pixels are 312 x 324. The "circle" is 30 x 30.
I set the grid imageView to fill, with a width-to-height ratio of 312:324 and a width of 0.75 to superview.
I set the circle imageView to fill, with a width-to-height ratio of 1:1 and a width constraint of 30:312 of the grid imageView.
Here is the result:
You would need to calculate the run-time" ratio for placement, but that's pretty straight-forward.
Edit:
I whipped up a simple example - has buttons to move the circle based on the intersection points: https://github.com/DonMag/GridScale
stretch image right and left side
centre arrow remain as it is
i tried with it but centre down arrow position is not properly set by me.
You can't do this with sliced images.
The area between the edges will stretch or repeat in order to fill the area. You can't also preserver the centre section of an image this way.
What you might be better doing is creating a custom drawn view using either CALayer or drawRect.
I am trying to put the image at the top of of my device and these are the constrains that i am applying
The result that i am getting by applying this result is
so there is some black space left at the top, i want that my image should stick to the top, i want to conserve the aspect ratio of the image and can't clip it so i can't use aspect fill. Can someone help me out with this
I have a simple UIImageView and an image. I want to fit the image in that UIImageView but I don't want the image aspect ratio to change and I also don't want any dead spaces. ( black bars on the sides etc') I don't care if the image is zoomed in all the way as long as those 2 rules are applied.
Is there a build in setting for that? I tried all the Scale To Fill and Aspect Fill etc' but couldn't find what I'm looking for.
For example: UIImageView is 300x300
image is 200x250. The image will zoom in until all the areas of the UIImageView are filled.
For a UIImageView you can use Aspect Fill in the properties to do this.
But you may have to tick the box "Clip Subviews" otherwise the image will spill outside the image view frame.