In my HypnosisViewController.m I have this code for adding a UIView subclass, HypnosisView to the window. My goal is to set the property UIColor circleColor of my HypnosisView instance when a UISegmented control changes its value.
- (void) loadView
{
CGRect frame = [[UIScreen mainScreen] bounds];
HypnosisView *v = [[HypnosisView alloc] initWithFrame:frame];
CGRect segment = CGRectMake(200, 300, 75, 20);
UISegmentedControl *colors = [[UISegmentedControl alloc]initWithFrame:segment];
[v addSubview:colors];
[self setView:v];
}
then I would like from here to use an IBAction outlet as so, but xcode does not recognize my getter/setter method in my custom class when using this code:
- (IBAction)setRingColor:(id)sender
{
if ([sender selectedSegmentIndex] == 0)
{
[self.view setCircleColor:[UIColor redColor]];
}
}
How can I communicate this to my custom UIView?
You have to downcast it to its derived type.