- UIButton *button =[UIButton buttonWithType:UIButtonTypeRoundedRect];
- button.frame= CGRectMake(100.0, 200.0, 180.0, 60.0);
- // on click, which method to call
- [button addTarget:self action:@selector(onClickMethodToCall:) forControlEvents:UIControlEventTouchDown];
- // title of button
- [button setTitle:@"Click Me" forState:UIControlStateNormal];
- // if has to have a image
- UIImage *image =[UIImage imageNamed:@"image.png"];
- [image setImage:img forState:UIControlStateNormal];
- // finally add
- [view addSubview:button];
↧
How to create a UIButton programatically in iOS?
↧