Another simple problem with changing the background color of a UIButton. Therefore, I decided that I had a little thought in creating an image or for viewing.
I created a button in the storyboard and plugged it into a power outlet. In my VC class, I have the following
.h
@property (nonatomic, readwrite, strong) IBOutlet UIButton *uiLoginButton;
.m
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"%s and frame rect %@", __PRETTY_FUNCTION__, self.uiLoginButton);
CGRect buttonRect = CGRectMake(50, 50, 100.0, 100.0);
self.uiLoginButton = [UIButton buttonWithType:UIButtonTypeCustom];
self.uiLoginButton.frame = buttonRect;
self.uiLoginButton.backgroundColor = [UIColor redColor];
NSLog(@"%s and frame rect %@", __PRETTY_FUNCTION__, self.uiLoginButton);
}
No. I set the values ββin CGRectMake randomly since the frame of the IBOutlet button is 0. How did it happen?
What is the correct way to change the color of a button?
source
share