Nirav Bhatt
Nirav Bhatt

Reputation: 6969

Set background texture for my iphone app UIView

I am newbi to iphone apps as well as to this forum.

I want to place a background texture for my UIView that should cover the whole iPhone screen. I have controls placed on this view currently. Later on, I would like all my controls to be transparent, so user must be able to work with controls, but not see anything except its text.

Here is what I tried:

Created a UIView derived view - with simple background color, no image Placed my controls - UIButtons, labels Programmed all of them correctly to reflect my game logic

Now I have a change of my mind. I think its lot better to have a background texture for my view, as well as controls.

1) I tried things mentioned at: Adding A Background Image In Interface Builder but this covers my UI controls.

2) Through Interface builder, I tried drag-dropping the texture image onto my view (which in turn, probably, created a UIImageview with background image = my texture). But that again hid every of my past work. Then I started playing with alpha value (0.1, 0.8 etc) - it gives me some result, but I am no longer able to design my controls. Nor I am able to click (=touch) them at runtime anymore.

Please give me a method that will not disrupt my work so far (I hate redoing all the outlet wiring of my controls), but still allow me to achieve my goal.

Forgive me if I asked too silly thing, or did not search enough. This is my first question, and will be glad to try any helpful solution!

Many thanks!

Upvotes: 1

Views: 1689

Answers (1)

Nandeep Mali
Nandeep Mali

Reputation: 4456

How about:

self.view.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"texture.png"]];

Upvotes: 5

Related Questions