When a user touches down on my UIButton subclass, I want the the button to expand in size outward. However, when I manipulate the button’s frame in the touchDown event nothing happens. The touchDown event is being called and I can change other properties such as color, but not the frame.
What is going on here?
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self addTarget:self action:@selector(touchDown:) forControlEvents:UIControlEventTouchDown];
}
return self;
}
- (void)touchDown:(id)sender {
self.frame = CGRectInset(self.frame, -20, -20);
}
EDIT: The button is nested deep within a view hierarchy, but each superview has clipsToBounds = NO.
The problem was that my superview implements layoutSubviews and resets my subview frames each time I update their frame.