Posted By

arpit on 07/20/09


Tagged

iphone UIButton


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

cgrainger
avanadra
sb
cnathan


Add a button with background image


 / Published in: Objective C
 

URL: http://pointlessprogrammers.com/?p=100

  1. - (void)viewDidLoad {
  2. contentView = [[UIImageView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
  3. [contentView setImage:[UIImage imageNamed:@"284.jpg"]];
  4. [contentView setUserInteractionEnabled:YES];
  5. self.view = contentView;
  6. [contentView release];
  7. UIButton *startButton = [[UIButton alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 180.0f, 130.0f)];
  8. [startButton setBackgroundImage:[[UIImage imageNamed:@"squareButton.png"] stretchableImageWithLeftCapWidth:110.0 topCapHeight:0.0] forState:UIControlStateNormal];
  9. [startButton setCenter:CGPointMake(195.0f, 208.0f)];
  10. [startButton addTarget:self action:@selector(playSound:) forControlEvents:UIControlEventTouchUpInside];
  11. [contentView addSubview:startButton];
  12. [super viewDidLoad];
  13. }

Report this snippet  

You need to login to post a comment.