I wanted to display a png image in the center of my main view controller. Do I have to use a UIImageView or just add the image to the view itself?. I don't want to cover the whole view but just in the center with a fairly large image. What would be the ideal dimensions of the image be for all iOS devices (supporting iOS 6.0 and above)?.
The easiest way is to use UIImageView like you said. There are ways of manipulating other classes to display images, but it's more code overall and more confusing to look at. As for the ideal dimensions, it depends on the aspect ratio of your image and the rest of your view.
Related
Hey everyone I've been stuck on this issue for the past few days. It's pretty hard to describe so I uploaded a video for it on a GitHub repository:
https://github.com/DJSimonSays93/PresentationController
It involves custom view controller transitions using present and the delegates UIViewControllerTransitioningDelegate and UIViewControllerAnimatedTransitioning
The "problem" is straightforward, now let me see if I can describe it in words.
You've got two image views showing, say, the basil image: the one in the scroll view, and the full-screen one when you present. They are both set at Aspect Fill. But the aspect ratio itself is different for these two image views. Therefore, in order to be displayed in Aspect Fill in a different image view, the image shifts in the way it is shown.
The reason you find this upsetting at the end of the dismiss is that you don't notice it happening at the start of the present, but if you slow down your video (you can turn on Slow Animations on the simulator, it will help), you can see it there too:
When you tap an image in the scroll view, there is a jump as the image changes its display for the new image view, and then the image view grows to its true size as the transform is removed (animated).
When you tap the full screen image, the transform is applied (animated) and then there is a jump as the image view is taken away to reveal the old image view that was behind it.
If you make both image view Scale To Fill, that won't happen. Of course then there is a distortion of the image, but it is the same distortion so that the image appears to grow and shrink smoothly right the way through. Try it and you will at least be satisfied by the sense of what I'm saying.
(See https://www.apeth.com/stretch.gif.)
If you don't want to do that, then you will have a lot more work to do; you will need to figure out how to actually compensate for the difference in aspect ratio by changing the aspect ratio of the image to match. Or, you could make the goal size of the fullscreen image view match the aspect ratio of the small image view (and part of it will just end up offscreen).
The point is, you cannot display the same image using Aspect Fill in image view with different aspect ratios and expect the image to appear the same way in both. Either the image needs to be different (to compensate) or the aspect ratios need to be the same.
I have a very simple requirement here but I'm looking for a solution for a while. I want to take a profile picture form the camera roll or camera and display it in two different image views (different sizes). I don't want any of these images stretched or miss any part of the image. If I use aspect to fit, top side of image is cut from smaller image view and some parts missing on the bigger image view. If I set it as scale to fit, it will get stretched!
I'm not sure how some mobile apps work. Do they save different image sizes in their server or they change the size of the image. I saw many posts how to change image size without changing aspect ratio. But I don't think it is possible to avoid stretched effects. I used some of those code to change size of image, it gets stretched all the time.
Is there any way to save the image from camera roll one time with size of 140*200 and one time 160*200? So I can use 140*200 for image views that size. But what if I have different devices and different sizes.
I'm currently working on a collage application where users can combine multiple images into one collage (in a grid like layout, like 2x2). I worked on a couple of examples where coders used a UIView to which the images were added as Subviews. The subviews itself are zoomable and scrollable, so that the images can be adjustet inside their boxes.
The results are then exported as a JPEG reprensentation. While the results are okish, the problem is that output from the UIView only is as big as its screen size (640x640 for a 2x Screen on an iPhone 4 / 5). I was wondering if there would be better way to maybe compose a higher resolution image from the original image sources with consideration of the changes made in the view.
The View
I'm making my first iphone game using swift/xcode with gimp to draw the graphics. I'm having trouble understanding what size I should make the image in gimp to use it for the background of my iphone game.
The various devices have different screen sizes, so presumably you will want your image to adapt. Thus it really isn't about your image but about the image view that will display it (assuming you're using an image view). The things to think about are:
How to use constraints to pin the edges of the UIImageView to the edges of the screen.
How to set the content mode of the UIImageView so that it displays the image acceptably on all device sizes.
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:.