I have added a UIButton in a Viewcontroller on the storyboard. I subclass this button, set an outlet to the ViewController and I am able to change it's background colour with the public changeColor function.
But I want to do this in a constructor so that I don't have to do it from outside. I try figure out what constructor is called by default, but in the example below i get no outputs. Is there a constructor that is called by default only by adding an object to the storyboard?
- (id)initWithFrame:(CGRect)frame
{
NSLog(@"constructor");
self = [super initWithFrame:frame];
if (self) {
// Initialization code
}
return self;
}
-(id)init {
NSLog(@"constructor");
self = [super init];
if (self) {
// Initialization code
}
return self;
}
-(void)changeColor{
[self setBackgroundColor:[UIColor redColor]];
}