I'm writing custom control with segments (like UISegmentControl)
I have to use IBInspectable
params.
I have number of controls
@property IBInspectable int numberOfSegments;
And here how I draw this segments:
-(void) drawForAmountOfSegments {
float segmentWidth = self.frame.size.width / numberOfSegments;
float segmentHeight = self.frame.size.height;
for (int i = 0; i < numberOfSegments; i++) {
CGRect sgRect = CGRectMake(segmentWidth * i, 0, segmentWidth, segmentHeight);
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button addTarget:self
action:@selector(segmentSelected:)
forControlEvents:UIControlEventTouchUpInside];
button.tag = i;
button.frame = sgRect;
button.backgroundColor = custom;
[self addSubview: button];
}
}
Now I want to set titles for this buttons (segments) And I want to select editing control from IB, like in segmentControl.
As I understand, I need an array of all segments, and by selecting one of it to edit its title.
But I can't to set NSArray
as IBInspectable
Any suggestions how to solve this problem?
* Edit *
For example, I need to select from enum of segments single segment, and set its params. Select first segment -> set its title (I can't understand how to realize it with IBInspectable)
You can use User Defined Runtime Attributes
from Identity Inspector
.
All inspectable attributes actually add values there.