Basically, I have a view that can have an unlimited amount of UIViews inside of it. I want to be able to set self.numberOfSections = 8
or self.numberOfSections = 2
and then have that same number of UIImages
generated respectively that can then be manipulated.
Currently I have many IBInspectible
images in my code that appear no matter if I have 2 numberOfSections or 100 numberOfSections. I would like to somehow be able to create UIImages
based off of my numberOfSections number.
If I set Number Of Sections to 2 here - I can set the images in the story board, but all the other IBInspectable elements appear too that won't be used because there are only 2 sections. Is there a way to only have the ones that are needed appear? I want to set images in the storyboard. Is there a way to refactor this down so as not to have so many IBInspectables?
This is how I set the images to the various programmatically generated views in code.
-(void)drawRect:(CGRect)rect
for (int i = 0; i < self.numberOfSections; i++) {
NSString *rotaryName = [NSString stringWithFormat:@"rotaryImage%d", i + 1];
id rotaryNameValue = [self valueForKey:rotaryName];
[self.sectorView setValue:rotaryNameValue forKey:@"image"];
}
}