2010-06-23 3 views

Répondre

0

La méthode la plus simple serait de simplement superposer un UIImageView derrière le UILabel. Si vous voulez le rendre plus robuste, vous pouvez créer une sous-classe UILabel qui expose une méthode ou une propriété pour définir l'arrière-plan de l'image et ajouter l'image à elle-même.

CGPoint labelPos = CGPointMake(123, 234); 
UIImage *theImage = [UIImage imageNamed:@"button_bg.png"]; 
UIImageView *theImageView = [[UIImageView alloc] initWithImage:theImage]; 
theImageView.frame = CGRectMake(labelPos.x, labelPos.y, theImage.size.width, theImage.size.height); 
UILabel *theLabel = [[UILabel alloc] initWithFrame:CGRectMake(labelPos.x, labelPos.y, 100, 50)]; 
theLabel.backgroundColor = [UIColor clearColor]; 
// ...label config... 

[self.view addSubview:theImageView]; 
[self.view addSubview:theLabel]; 

[theImageView release]; 
[theLabel release]; 
Questions connexes