button 创建的代码:
- (IBAction)addButton:(id)sender
{
CGRect frame = CGRectMake(30, 36, 100, 50);
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.frame = frame;
button.backgroundColor= [UIColor clearColor];
button.tag = 1000;
[button setTitle:@"我爱你" forState:UIControlStateNormal];
[button addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];
button 点击的代码:
-(IBAction)buttonClicked:(id)sender
{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"woaini" message:@"woania" delegate:self cancelButtonTitle:@"qued" otherButtonTitles: nil];
[alert show];