UiPopOver in Iphone - ios

I have an image of the UiPopOver
I want to make it bigger or smaller based on the text that i want to display in this. My plan is that i will adda text view inside the image view and scale it accordingly. I am facing difficulty in scaling the image to bigger or smaller.
For example if i know that the text that will fit in it have size of CGSize(80, 100), the how i can scale this image view to a specified size without pixelation.
Any help will be highly appreciated.

you can make the resizable image with the following insets (their positions marked by the colourful lines below), that will do the job for you:
you can find more information about how you can me a resizable image in the UIImage Class Reference, the related method's name is –resizableImageWithCapInsets:.

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.

Stretch background image to fit

I'm trying to get the background image in my reveal.js presentation to adjust its aspect ratio to fit the screen. Changing the size seems simple enough via
data-background-size=...
but I can't find anything that shows me how to make the image stretch to fit the screen.
You can do it manually entering two parameters: data-background-size="800px 600px" for example.
This stretches the image to fit the slide, keeping its aspect ratio:
data-background-size="contain"
The attribute is mentioned in the Backgrounds section of the documentation.
For possible values of data-background-size, see the MDN documentation.

UIImageView - anyway to use 2 content modes at the same time?

So in my scenario, I have a square that is (for understanding's sake) 100x100 and need to display an image that is 300x800 inside of it.
What I want to do is be able to have the image scale just as it would with UIViewContentMode.ScaleAspectFill so that the width scales properly to 100.
However, after that, I would like to then "move" the image up to the top of the image instead of it putting it inside the imageView right in the center, basically what UIViewContentMode.Top does. However that doesn't scale it first.
Is there anyway to do this type of behavior with the built in tools? Anyway to add multiple contentModes?
I already had a helper function that I wrote that scaled an image to a specific size passed in, so I just wrote a function that calculated the scaled image that would fit into the smaller square I had similar to the size AspectFill would do, and then I wrote code that would crop it with the rectangle size I needed at (0,0).

iOS Aspect Fill Image Resizing with Content Aligned to Left/Top Edge

I am developing a universal app for iOS-7. this particular question is specific to iPad only. I want to place an image as background of root view of a View Controller i.e. the image should fill the whole screen. The 1x image has size:768x1024. This works for Portrait orientations as non-retina resolution of iPad is also 768x1024 in portrait. In Landscape however the image does not fit. I have tried using ScaleToFit but since aspect ratio of image is not preserved I can not use ScaleToFit(their are things in image which look odd when not scaled proportionally in both axis). AspectFill resizing seems most suitable for my need, but their is a small problem. As defined in Apple Documentation "The content is resized to completely fill the bounds rectangle, while still preserving the aspect of the content. The content is centered in the axis it exceeds.". I do not want the content to be centered in axis in which it exceeds, I want it to be aligned to top/left edge.
So basically I want two things:
Aspect Fill
The content remains aligned on the Left/Top edge.
Is it possible to achieve this. Any code-snippet will be great.
Thanks
You will have to subclass the View Controller's view and manually scale and align.
Look at the code snippets in THIS answer.
Adjust imageViewXOrigin and imageViewYOrigin to align however you want.
Really the only way to get around the content fill mode is to have two different images, one for each orientation. I'd suggest changing the image in the view controllers willAnimateToOrientation: method so that you can put the image changes inside UIKit's animation block.

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.

Resources