2010-10-27 7 views

ответ

1
UIButton *playButton = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain]; 
playButton.frame = CGRectMake(110.0, 360.0, 100.0, 30.0); 
[playButton setTitle:@"Play" forState:UIControlStateNormal]; 
playButton.backgroundColor = [UIColor clearColor]; 
[playButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal ]; 

UIImage *buttonImageNormal = [UIImage imageNamed:@"blueButton.png"]; 
UIImage *strechableButtonImageNormal = [buttonImageNormal stretchableImageWithLeftCapWidth:12 topCapHeight:0]; 
[playButton setBackgroundImage:strechableButtonImageNormal forState:UIControlStateNormal]; 

UIImage *buttonImagePressed = [UIImage imageNamed:@"whiteButton.png"]; 
UIImage *strechableButtonImagePressed = [buttonImagePressed stretchableImageWithLeftCapWidth:12 topCapHeight:0]; 
[playButton setBackgroundImage:strechableButtonImagePressed forState:UIControlStateHighlighted]; 

[playButton addTarget:self action:@selector(playAction:) forControlEvents:UIControlEventTouchUpInside]; 
[self.view addSubview:playButton]; 

Источник: http://jainmarket.blogspot.com/2009/04/create-uibuttonbutton-with-images.html

Смежные вопросы