CPGraphHostingView background image issue in IPhone? - iphone

I have a CPGraphHostingView to display a graph. I changed its theme to clear color, and add a UIImageView to the CPGraphHostingView in order to add an image as the background of the graph.
But then the image will give only the mirror image like copy of the original image. So when I am taking the screenshot of that view I'm getting the mirror image copy of the original view. How to solve this?

Don't add any subviews to the CPGraphHostingView. If you must use a UIImageView, make it a sibling of the hosting view (i.e., they are both subviews of the same parent).
The easiest way to put an image behind a graph is to set the fill.
CPTImage backgroundImage = [CPTImage imageForPNGFile:pathToTheImage];
graph.fill = [CPTFill fillWithImage:backgroundImage];
You can also create the image using +imageWithCGImage: or +imageWithCGImage:scale: if you already have your background image loaded into a CGImageRef.

Related

How can i make multiple customized uiimageview frame in one view?

I have to make view where there will be multiple curved or irregular shaped imageview. Now when i will touch a UIImageview then it will import image from photo gallery.For example: Suppose
I have an UIView with background image.
On that view i have 3 irregular shaped UIImageview.every UIImageview is attached with each other.
Now suppose i have touch in the first UIImageview then it will take an image from photo gallery.
When i have imported the image then that image will be as the background image of the UIImageview.
I have to make sure that if my UIImageviewis smaller then its background image then i will able to move the image or rotate the image or scale or zoom the image to adjust the image according to the size of UIImageview.
How can i do that whole process??? any help by link,source code,tutorial or anything else will be cordially appreciable.
Basically my first priority is that how can i make those irregular shaped UIImageView pro-grammatically.
IF ANY FURTHER QUERY TO ASK THEN PLEASE DON'T HESITATE.
Thanks In Advance
The one way of doing this is as follows:
Subclass from UIImageView set touchesBegan methods for each UIImageView for import image, setting on background and whatever you want to do on touch.
What does 'attached' mean? If all of them should move together, then, again, you have to deal with it in touchesBegan methods, sending messages like 'Hey views, i've moved on this vector:[vector], please do it too'.
In pt. 3.2 i didn't get your point. :( You can set in UIImageView subclass self.contentMode = UIViewContentModeScaleAspectFit or UIViewContentModeScaleToFill, so its image will always fit the view.
About irregular shape, did you read links below? I suppose there's not an super easy way to do it :(
http://www.iphonedevsdk.com/forum/iphone-sdk-development/76923-hittest-collision-for-irregular-shaped-uiviews.html
Draggable UIImageView Partially Transparent & Irregular Shaped
Simple way of using irregular shaped buttons

Tiling an image in a UIVIew

I am trying to tile an image for an app I am making. I am making rope that I can set the length for. In order to do this, I have a function that takes my rope length, sets the frame size accordingly, and then sets the background color like this:
(picture is a UIView)
picture.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"Rope.png"]];
The view is blank. I tested it before by displaying an image by making picture a UIImageView instead, and it worked, but it won't show up anymore.
EDIT: I have now tried a few different methods of tiling, the best I can get is a stretched image. I need a working way to tile an image and get the output of my tiled image into a UIImage, UIImageView, or UIView.
Not sure what I did wrong but it is working now.

UIImageView not showing the background View if the image has transparent regions

I have a UIView has some labels and buttons on it.
Next I also have a image which has a square area that is transparent, now
if I create a UIImageView and add this image which has transparent regions I am not able to see the background view (which has buttons and labels) through this transparent image.
If I play with the alpha value that doesn't work as intended which is to see the transparent regions exactly as it would have appeared on the UIView which has the labels and buttons.
UIImage* image = [UIImage imageNamed:#"TI1.jpg"];
UIImageView* imageView = [[UIImageView alloc] initWithImage:image];
[self.view addSubview:imageView];
Also I would be interested to know if there is other way to achieve what I am trying to achieve.
Basically I want to highlight a certain area of the view which has buttons/labels and make the rest of the area greyed out. My idea was to have this UIImageView with transparent regions in image to achieve that.
Thanks
Ankur
Try setting imageView.opaque = NO;
UIImageView inherits from UIView. According to that class's docs:
This property provides a hint to the drawing system as to how it
should treat the view. If set to YES, the drawing system treats the
view as fully opaque, which allows the drawing system to optimize some
drawing operations and improve performance. If set to NO, the drawing
system composites the view normally with other content. The default
value of this property is YES.
Also, not sure that JPG even supports transparency, so try exporting the image as a PNG to ensure you get the results you're looking for.

UIImage inside table view cell

Inside my table view for each cell I have an image along with some text and other stuff. When I select a cell I want the image also to be covered with blue overlay. Right now all other stuff excluding image is getting selected and a blue overlay covers the cell.
How to achieve this?
You won't be able to have that blue overlay to cover your image. The blue gradient is the backgroundView of the cell, whereas your UIImage is either drawn inside the contentView or added to it as a subview.
A possible workaround would be to add a CALayer on top of the whole cell that would mimic the default blue background.
It seems like there should be a way to do this without modifying your image, but all I can find so far is to specify a new image when the cell is selected. UIImageView has a property for both image and highlightedImage, so it would seem you need to provide your own image to use when the cell is selected, so you would need to set cell.imageView.image and cell.imageView.highlightedImage.
Sam's workaround would be a good approach, also. Especially if you don't want to provide your own image

How to erase particular portion without effecting other part in UIImageView?

I have one UIView with an UIImageview in which i have an image downloaded from web service. Now i try to draw with drawRect: in it. I want to erase part of my drawing same as like eraser without effecting background image downloaded from web service.
So how can i do that?
Thanks
If you simply want to "replace" part of the UIImageView with rendered primitives, rather than editing the image data, just place a UIView with a [UIColor clearColor] background color on top of the UIImageView and draw into that overlay UIView with a non-transparent color.
I don't think your looking at it the right way.
How I would do this is:
1) get the bitmap in the UIImageView
2) change the pixels/areas that you want to change
3) set the altered bitmap in your view