tags:

views:

90

answers:

2

Hi, im new to the iPhone SDK and development. I work for a company that is looking to create some proof-of-concept iPhone applications and one of the requests/potential features was using a video file as the background for the application.

I understand that from a user experience pov this isnt necaserrily classed as best practice however if I can at least prove that this can be done whilst also listing the pro's and con's of doing so this would benefit me greatly.

Any help on this subject is greatly appreciated :)

Regards,

Wayne

A: 

Not sure if it's possible, but a major con would be the heavy load to the iPhone's CPU, available RAM, and battery level in doing this.

ceejayoz
I realise this and I have voiced my concerns - this is meant to be a usability app rather than something of eye candy however they still are asking me to prove it either way. Ive read a through articles on animated backgrounds but so far nothing as far as video is concerned.
Wayners247
+1  A: 

You should be able to implement this through Quartz Core using layers (see the CALayer class documentation). Indeed, you can have layers hierarchies.

However, you should carefully, as already stated, take into account the heavy load. For just a few seconds, it may be acceptable though.

Basically you associate each UIView to a different layer, then the layers are rendered together providing a single, composite layer. Besides, you can also apply transforms and animations to layers.

You need to import the QuartzCore header and do something like

#import <QuartzCore/QuartzCore.h>
UIView *myView = [[UIView alloc] initWithFrame...
UIView *myMoviewView = [UIView alloc] initWithFrame...

CaLayer *myViewLayer = myView.layer;
[myViewLayer addSubLayer: myMoviewView];

Then, when myView appears on the screen, all the sublayers are merged together and rendered on screen. What happens is that each view renders its layer, while myViewLayer is rendered merging together the two layers.

You can have as many layers as you like. You can create an arbitrary hierarchy by using the CALayer methods

– addSublayer: – removeFromSuperlayer
– insertSublayer:atIndex:
– insertSublayer:below:
– insertSublayer:above:
– replaceSublayer:with:
unforgiven
Excellent response, thanks very much for taking the time to explain this to me :)
Wayners247