Sounds like you're on the right track, so I'm not sure how helpful I can be. Create your public initializers and public setStyle methods. Sorry for any typos. I'm doing this without an editor.
.h
-(id)initWithFrame:(CGRect)frame;
-(id)initWithFrame:(CGRect)frame style:(MyStyleEnum)myStyleEnum;
-(void)setStyle:(MyStyleEnum)myStyleEnum;
.m
//here's your default method which passes your default style to your custom init method
-(id)initWithFrame:(CGRect)frame {
return [self initWithFrame:frame style:myStyleEnumDefault];
}
//your custom init method that takes a style
-(id)initWithFrame:(CGRect)frame style:(MyStyleEnum)myStyleEnum {
self = [super initWithFrame:frame];
if(self) {
[self setStyle:myStyleEnum];
}
return self;
}
//this can be called after initialization
-(void)setStyle:(MyStyleEnum)myStyleEnum {
//make sure the view is clear before you layout the subviews
//[self.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];//not needed adjusting constraints and not repopulating the view
//change the view constraints to match the style passed in
//the acutally changing, should probably be done in separate methods (personal preference)
if(myStyleEnum == myStyleEnumDefault) {
//change constraints to be the default constraints
} else if(myStyleEnum == myStyleEnumA) {
//change constraints to be the A constraints
} else if(myStyleEnum == myStyleEnumB) {
//change constraints to be the B constraints
}
}