Iphone: Programmatically adding a UIButton to a view


/ Published in: Objective C
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.