This is a discussion on How To a Make UIButton with Background Image Programmatically within the iPhone/iPad Programming Tutorials forums, part of the Programming Section category; Hello, Here is how to code a UIButton with a Background image. In you ViewController.m file: Code: UIButton *roundedButtonType = ...
Hello,
Here is how to code a UIButton with a Background image.
In you ViewController.m file:
Code:UIButton *roundedButtonType = [[UIButton buttonWithType:UIButtonTypeCustom] retain]; //Creates a UIButton roundedButtonType.frame = CGRectMake(200, 368, 95, 37); //sets the coordinates and dimensions of UIButton roundedButtonType.backgroundColor = [UIColor clearColor]; //sets the background color [roundedButtonType addTarget:self action:@selector(returnmainview:) forControlEvents:UIControlEventTouchUpInside]; //sets the Background image [roundedButtonType setTitle:@"title" forState:UIControlStateNormal]; //set the title [roundedButtonType setBackgroundImage:[UIImage imageNamed:@"chrome.png"] forState:UIControlStateNormal]; //sets the background Image [roundedButtonType setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
IF YOU NEED ANY HELP PLEASE DON'T HESITATE TO ASK BY LEAVING A REPLAY BELOW![]()
Last edited by Fahad; 01-10-2011 at 06:08 AM.
MozyMac Founder,Chairman and CEO
MacBook Pro Unibody late 2008 2.4Ghz 4GB ram 250GB HD
MozyMac Youtube Channel