how to merge two images iphone with one image variable height - iphone

I have two images.I want to display like where the first image end the next one should start.
both have same width but the height of the first one is variable .
I am not getting perfect code for it .
please help me
I am using one above another its displayed as a overlapped ??

Take 2 UIImageView and set their frame in such a way that when the first imageView ends you start the second imageView and in both the imageView set your image. Whatever height it is its gonna set in that imageView Itself....
hAPPY cODING...

Related

How do I position a label and a button on an image so that even if the image is scaled they are at the same place on the image?

I have an almost complete app. I want to use auto layout but even though I have searched a lot about this subject I could not find an answer that I could use. I can get it to show correctly on one screen size but not on another... Here is my question
How do I put the necessary constraints so that even if the counter is scaled for the different sized devices,the label and the button are at the same place on the image? (the image is a png image)
I would really be glad if you can answer or direct me to an answer that shows how to do a similar thing.
This is what I want
And this is what happens if I try doing it with auto layout and on a different screen size.
This is not the same image that I am using in my app but it will give you an idea.)
Thanks again
Edit:
Thanks for the answers but as pointed out in the comments, 1st answer does not provide a way to scale the image for different screen sizes.
Second answer provides a way but I could not understand the 2nd part of the answer.I need a little bit more detail. I would be glad if there is anyone out there who can help me on this issue.
I am still struggling with this issue. If I follow the 2nd answer Xcode says I need X position,width for the first filler view and Y position,height for the 2nd filler view.I am stuck at this point. I am not sure what value to give to these views.
You have to add constraints with respect to the image view. I have created a small project with your image. This should help you get started.
https://1drv.ms/u/s!Aq8sK_MQLIL9gxMl-lBOMHkToudU
Because the image size will change on different screen sizes, you can't set constant constraints. What you need is proportional constraints.
Set your UILabel and UIButton to have the width and height proportional to the UIImageView width and height respectively.
To do that: Click on your UILabel
and Ctrl Drag it over the UIImageView, selecting Equal Widths and Equal Heights.
Let's say your UILabel has a width of 100px and your UIImageView has a width of 500px. Edit the constraints that you have just set, and set the multiplier to be 100:500
This will make sure that any modifications on the UIImageView width, will affect the UILabel width accordingly. Do the same for height constraint.
Repeat same steps for UIButton.
The top/bottom/trailing/leading constraint cannot be set proportional to the UIImageView size unfortunately, but you can have filler views - transparent views that can mimic the layout constraints.
You will need two filler views: one for top constraint:
(set its height to be proportional to the UIImageView height)
and one for leading constraint
(set its width to be proportional to the UIImageView width)
I can make a small video for you if this is not clear enough.

Set size of UIImageView

I have a very simple question,
I am working in the storyboard and is dragging a uiimageview into the viewcontroller. I configure the imageview to be square (like 100*100). I now set the image to something that has another aspect ratio (like 100*150). When I build the app I expect the imageView to be square (100*100) as i have set in the constraints, but instead it shows the imageView with the image size. So in other words, what I am asking is: How can I set the imageView to the exact size I want so it overwrites the image size? Hope this makes sense, else I can try to explain it a bit better.
Did you set imageView.clipsToBounds = true :)

What's the difference between setBackgroundImage:Forstate and setImage:Forstate:

I am trying to set a image for a UIButton.
I don't know the difference between the setBackgroundImage:Forstate and setImage:Forstate:
Could anyone help me out?
Thanks and best regards.
setImage:forState: sets the image as the actual content of the button. For example, you can not see the button title even though you set it, because you have set an image as the content.
setBackgroundImage:forState: sets the image as the background. In this case, you can set the title and it is displayed on top of the image.
setBackgroundImage: follows the frame, i.e. if u change the frame, the background image is streched or shrinked with it. Contrary on the setImage, its not the same. The image takes its own size. In setImage the image is the actual content of the button.
The difference is in the framing
I will explain you with the help of example suppose your image size is 40*40 and button frame is 20*20 then if you use setBackgroundImage:forState: method the image will be displayed in 20*20 frame and if you use setImage:forState: method you will see a button with image size of 40*40 frame.
This is the difference.
Happy Coding!!

TTTableSubtitleItem squishes image and does not clip it?

I am using a TTTableSubtitleItem with UITableViewStyleGrouped. When viewing the tableView, the image that is in the TTTableSubtitleItem gets skewed to fit the image view (rather than just placing image without changing dimensions) and also the image does not get a rounded edge when it is the first item in the section.
Does anyone know of a way to fix these two issues?
I needed to subclass TTTableSubtitleItem and draw my own images.

iOS: How to display multiple images dynamiclly in imageview?

Hi I am new to iPhone.
What I need is, have to display only one image in one case, two images in another case like wise and for that I am using a UIImageview with IBOutlet.
How can I display multiple images in single imageview?
Please help me post some code.
Thank you.
An UIImageView can only display one image at a time. You will either have to use several UIImageViews or compose your images into one file before displaying it.
I think you should subviews ot type UIImageView to your main UIImageView.
The "hard" task will be to compute the boundaries of each subview, according to the prefered layout. Use the image property of UIImageView to set the image for each subview (don't worry about resizing, UIImageView will do the work for you)