In iPhone SDK, there is no setBackgroundImage function for setting an background image of an UIView. But actually, this can be done by the setBackgroundColor function. The following code will set the background view to Red.
1 | self.view.backgroundColor = [UIColor redColor]; |
So if you want to set a picture as an background image of a view, just initialize anUIColorinstance with an image and set it to the view.
1 | UIColor *background = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"anImage.png"]]; |
2 | self.view.backgroundColor = background; |
3 | [background release]; |
Please note that you have to set all the items which are in front of the background view to clearColor such that they will not cover the background image.
hogya yupieeeeeeeeeeee =))
No comments:
Post a Comment