The problem is this line:
MyButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
It should be:
MyButton *button = [MyButton buttonWithType:UIButtonTypeRoundedRect];
As you had it you were creating an instance of UIButton
instead of MyButton
.