You need to create an outlet for your CustomView
in your ViewController
. Delete the code that creates the new CustomView
instance and use _cv
to refer to the customView.
@interface ViewController ()
- (IBAction)Change:(id)sender;
@property (weak,nonatomic) IBOutlet CustomView *cv;
@end
Then, in the storyboard, connect ViewController's cv outlet to the CustomView
. Also, you'll need to implement the initFromCoder:
method on CustomView
.
- (id)initWithCoder:(NSCoder *)aDecoder {
if ((self = [super initWithCoder:aDecoder])) {
[self setup];
}
return self;
}