CGRect frame = CGRectMake(10.0, 30.0, 32.0, 29.0);
UIImage *buttonImage = [UIImage imageNamed:@"visit_icon.png"];
UIButton *stopButton = [[UIButton alloc] initWithFrame:frame];
[stopButton setTitle:@"Button" forState:UIControlStateNormal];
[stopButton setTitleColor:[UIColor blackColor] forState:UIControlEventTouchDown];
[stopButton setBackgroundImage:buttonImage forState:UIControlStateNormal];
stopButton.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
stopButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
[stopButton addTarget:self action:@selector(stopAction:) forControlEvents:UIControlEventTouchUpInside];
i was adding button to my root view controller is not working may be i need to add this as a sub view to my view how can i do that?