how to create a button in uiview programmatically in iphone

Solutions Collect From Internet About “how to create a button in uiview programmatically in iphone”

You can create dynamic buttons using the following code

    UIButton *but=[UIButton buttonWithType:UIButtonTypeRoundedRect];
    but.frame= CGRectMake(200, 15, 15, 15);
    [but setTitle:@"Ok" forState:UIControlStateNormal];
    [but addTarget:self action:@selector(buttonAction) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:but];