Posted By

BenClayton on 09/10/10


Tagged


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

umang_nine
bobbym245
cnathan


Iphone: Programmatically adding a UIButton to a view


 / Published in: Objective C
 

  1. UIButton* helpButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
  2. UIImage* helpImage = [UIImage imageNamed:@"help.png"];
  3. [helpButton setImage:helpImage forState:UIControlStateNormal];
  4. [helpButton setImage:helpImage forState:UIControlStateHighlighted];
  5. [helpButton setImage:helpImage forState:UIControlStateSelected];
  6. helpButton.frame = CGRectMake(320 - 32 - 12, 480 - 32 - 12, 32, 32);
  7. [self.view addSubview:helpButton];

Report this snippet  

You need to login to post a comment.