tags:

views:

212

answers:

2

hi guys , I am new to iphone Programming . I have a rectangle on which i display some data. I want to assign an image to its background. And is it possible that the data would be visible even after the image is assigned . Any idea how i can do it ? Thanks

A: 

CGRect is just a structure representing an abstract rectangle. You do not associate styling information (e.g. color, background image, etc.) to it because this does not make sense.

If you simply want to display an image on a window, drag the PNG image into your project, then you can find your image in Interface Builder, which can be put onto the window.

KennyTM
Thnx Kenny , nice to have such an instant reply. actually i have to resume working on a project. The previous developer left the company so i have to deal with things the way they are. There is a UIWebView instance and Rectangle is generated using this statement. self.webview.frame = CGRectMake(0,0,300, [output floatValue]+5); Now i want to assign an image to its background.This statement should work but it is giving an error message.[self.webview.frame setBackgroundView:IBimg]; It says"Cannot convert to a Pointer Type"I have declared IBImg as IBOutlet UIImageView *IBimg;
T. A.
@taimur: Since that's a UIWebView, the only method is to set the background image in the HTML page it's using.
KennyTM
@Kenny: Ahan thnks mate , i ll try this !
T. A.
@Kenny Tht didnt work , the data is coming from SQLite Database. And its only text. I have UIScrollView instance which has a subview UIWebView . The data is dispayed on it when a rectangle is made.self.webview.frame = CGRectMake(0,0,300, [output floatValue]+5); Its so furstrating tht i have not been able to solve it yet. Please help
T. A.
Thanks a lot for ur last reply , Appreciated!
T. A.
@taimur: "Text only" or "Coming from SQLite DB" has no contradiction with "set background image in HTML". Just put those text in HTML. And if it's text-only, it's better to use a UITextView than a UIWebView.
KennyTM
@Kenny i did it using these statements I was missing actually the statement in which i have to set background Opaque.[webview setOpaque:NO]; webview.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"Layer-1.png"]];
T. A.
A: 

You don't say how you are displaying your data, so it isn't possible to respond properly.

But in general, you create simple displays using Interface Builder, and can position a UILabel over a UIImageView, and can set the labels background to be transparent.

If you are drawing using drawRect:, then you probably shouldn't be. And yes, you can draw text over an image doing it this way, too.

Paul Lynch
Thnx Paul , nice to have such an instant reply. actually i have to resume working on a project. The previous developer left the company so i have to deal with things the way they are. There is a UIWebView instance and Rectangle is generated using this statement. self.webview.frame = CGRectMake(0,0,300, [output floatValue]+5); Now i want to assign an image to its background.This statement should work but it is giving an error message.[self.webview.frame setBackgroundView:IBimg]; It says"Cannot convert to a Pointer Type"I have declared IBImg as IBOutlet UIImageView *IBimg;
T. A.