Positioning a small image on the left edge of a UIImageView - iphone

I am placing a vertical image into a square UIImageView. It gets centered inside the square. Does UIImageView have a method to shift its contained image to the right or left?

I suppose you could try:
imageView.contentMode = UIViewContentModeLeft;
Otherwise I would recommend just putting the image view where you want it.

Related

How do I replace an image in a rotated and scaled UIImageView?

I have a UIView with a UIImageView as a subview. I modify the UIView with CGAffineTransformRotate and CGAffineTransformScale. The UIImageView subview also transforms with it automatically.
I want to replace the UIImage in the UIImageView subview with a new UIImage. When I do this, the image is the wrong size and rotation, because the original been scaled and rotated.
How do I replace the image subview and have it appear as the previous image did (same size/rotation/location)?
Take another UIImageView2 and put your previous image in it first. Then after you scale and modify the original image to a new one and want to see your original one, you can show the UIImageView2 image.
I found the bug, I was removing the original image and didn't know it.
imageView.image = nextImage;
Changing the image as above keeps the scale and rotation from the parent. No trickery involved.

Uiimageview inside uiscrollview position is not centered

I am developing an app for iPhone/iPad using Objective C. In my app I am having an UiScrollView which is having an UIImageView inside it. I can scroll and Zoom the Image inside the Scroll View.
All works fine.But my problem is that when I am loading the Image Inside a uiscrollview, its position is at something at center but not exactly.
I want that either my image should be center aligned or at the Top Left corner.
I had set the contentoffset to (0,0) and also tried setting the AutoresizingMask to different values.
Please let me know if somebody has any idea or solution.
contentoffset is something of the scrollview and is probably not right for this situation. If you want the image to be in the center do this:
imageview.center = scrollview.center;
If you want the image to be at the top left corner of the scrollview do this:
imageview.frame = CGRectMake(0,0,image_width,image_height);
Good luck!

how can i use UISCrollView paging with different heights?

I have a UIScrollView which shows multiple images when user swipe horizontally. But these images does not have the same height. The first image has height taller then the second.
1.What I want to do is when the person swipes, the next picture shown, is positioned at the top.
2.Also when using ScrollView's paging, the vertical scrolling is not smooth, it skips a whole frame. I've read that i cannot use ScrollView's paging to get the vertical scrolling smooth.
Any ideas?
For the 1st problem should I load nibs with images inside? How do I load a nib after swiping?
updated question:is there a way, i can load nibs(with its own scroll and imageview inside) as i swipe from left to right or right to left? because loading images side by side in the uiscrollview isn't going to do the trick.
set
[imageView setContentMode:UIViewContentModeScaleAspectFit];
this will show the image in proper aspect ... you don't have to worry about image size
[imageView setAutoresizingMask:UIViewAutoresizingFlexibleBottomMargin];
this will keep your imageView attached to the top of scrollView.
If you want every image to show at the top of the scrollView adjust the image.frame accordingly.
UIImageView *imageView;
UIImage *image = [UIImage imageWithData:loadTheImage];
imageView.image = image;
imageView.frame = CGRectMake(0, 0, 280, 480);
In the CGRectMake the first two values specify the padding for the image. The first is x value, the second y value. If both are 0, the image is displayed in the top left.
Does this make sense?

Image bounds not rect but custom

I want to add an image onto another image. But I know that imageview has a rectangular frame. Is there a way I can add an image without rect farme? Say, I want to add a pin onto an imageview. will it necessarily be a rectangular shaped imageview or can I add an image with frame shape that of a pin.
It is rectangular you can not add imgeView with other shape.
What you need is an transparent png that is your pin and added it to your original image view like an sub view.

How to move an image inside the imageview to the upper end of the imageView?

I have an imageView with contentMode UIViewContentModeScaleAspectFit. So it resizes the image without changing the aspect ratio. But the image inside the imageview is horizontally and vertically centred.
I don't want it to be vertically centred. How can I move this image to the upper end of imageview?
I think you should make a custom UIView in which you can have UIImage property (just like UIImageView has) and you need to over ride 'drawRect' method of UIView and draw the image at appropriate position using [image drawInRect:rect]; method, check the documentation you will find stuff about aspect ratio as well while drawing...
In UIImageView, image's x,y position can't be changed..