gameOverBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
gameOverBtn.frame = CGRectMake(0, 0, 150, 40);
gameOverBtn.center = CGPointMake(160, 230);
gameOverBtn.titleLabel.font = [UIFont boldSystemFontOfSize:24];
gameOverBtn.backgroundColor = [UIColor clearColor];
[gameOverBtn setTitle:@"Game Over" forState:UIControlStateNormal];
[gameOverBtn setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
[gameOverBtn setTitle:@"Restart" forState:UIControlStateHighlighted];
[gameOverBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];
[gameOverBtn addTarget:self action:@selector(restartBtnClicked:) forControlEvents:UIControlEventTouchUpInside];
UIImage *buttonImageNormal = [UIImage imageNamed:@"whiteButton.png"];
UIImage *stretchableButtonImageNormal = [buttonImageNormal
stretchableImageWithLeftCapWidth:12 topCapHeight:0];
[gameOverBtn setBackgroundImage:stretchableButtonImageNormal forState:UIControlStateNormal];
UIImage *buttonImagePressed = [UIImage imageNamed:@"blueButton.png"];
UIImage *stretchableButtonImagePressed = [buttonImagePressed
stretchableImageWithLeftCapWidth:12 topCapHeight:0];
[gameOverBtn setBackgroundImage:stretchableButtonImagePressed forState:UIControlStateHighlighted];
[self.view addSubview:gameOverBtn];
No comments:
Post a Comment