Changing In A Method Called By A Button
- (IBAction)MyButton:(id)sender
{
UIButton *ThisButton = (UIButton *)sender;
[ThisButton setTitle:@"1234" forState:UIControlStateNormal];
ThisButton.titleLabel.font = [UIFont systemFontOfSize:9];
}
Changing From Anywhere
In the .h file add this
IBOutlet UIButton *MyButton;
Link the button in interface builder
If your View could get unloaded you must release objects you’ve created (or you’ll have a memory leak) in #ViewController.m
//*************************************
//*************************************
//********** VIEW DID UNLOAD **********
//*************************************
//*************************************
- (void)viewDidUnload
{
[super viewDidUnload];
[MyButton release];
MyButton = nil;
}
//*****************************
//*****************************
//********** DEALLOC **********
//*****************************
//*****************************
- (void)dealloc
{
[MyButton release];
[super dealloc];
}
Then edit using it’s name
[MyButton setTitle:@"1234" forState:UIControlStateNormal];
MyButton.titleLabel.font = [UIFont systemFontOfSize:9];
Set Image
[MyButton setImage:[UIImage imageNamed:@"SomeImage.png"] forState:UIControlStateNormal];
Disabling A Button
MyButton.enabled = NO;
//or
[MyButton setEnabled: NO]
Hide A Button
MyButton.hiden = YES;
Other
MyButton.highlighted = YES; //Fills button with selection colour (as if it was pressed)