Many times we have the requirements to add the button programmatically as well as to the text on that button when we set the image on the button then text will be not visible.so, in that case write the following code
start code and new project view based application or singleview application
then inlace of the viewDidLoad method write the following code then run the application
you will find the button with the image and with the text just click on the butto.
-(void)ButtonClicked
{
UIWebView *wv = [[UIWebView alloc] initWithFrame:CGRectMake(0, 50, 320, 410)];
[wv loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://development-iphone-app.blogspot.com/"]]];
[self.view addSubview:wv];
}
- (void)viewDidLoad
{
UIButton *Btn = [UIButton buttonWithType:UIButtonTypeCustom];
[Btn setFrame:CGRectMake(10, 10, 300, 35)];
[Btn setBackgroundImage:[UIImage imageNamed:@"reviews.png"] forState:UIControlStateNormal];
[Btn setTitle:@"http://development-iphone-app.blogspot.com/" forState:UIControlStateNormal];
[Btn setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
[Btn setFont:[UIFont fontWithName:@"Helvetica" size:14.0]];
[Btn addTarget:self action:@selector(ButtonClicked) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:Btn];
[super viewDidLoad];
}
1 comments:
This is nice and more informative.......thanks for sharing this!!!
Mobile App Development Company
Android app Development Company
ios app development Company
Mobile App Development Companies
Post a Comment