How to Add a UIButton View in Code – Objective C iOS

Use the following code to add a Button to your view: Place the following code in “viewDidLoad” method of your view controller – 12345UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; button.frame = CGRectMake(0, 0, 40, 50); [button setTitle:@"1" forState:(UIControlState)UIControlStateNormal]; [button addTarget:self action:@selector(goToFun) […]