setContentEdgeInsets for different states of a UIButton?
I'm trying to give a button a depressed look, and to achieve that I need to bump down the title of the button when it's pressed. I think contentEdgeInsets is what I need, but I can't figure out how to set different values depending on the buttons state.
This works:
introButton.contentEdgeInsets = UIEdgeInsetsMake(0, 12, 0, 0);
This, however, doesn't:
[introButton setContentEdgeInsets:UIEdgeInsetsMake(0, 12, 0, 0) forState:UIControlStateNormal];
// warning: 'UIButton' may not respond to 开发者_运维知识库'-setContentEdgeInsets:forState:'
The debugger is giving you the answer: UIButton' doesn't respond to '-setContentEdgeInsets:forState:.
contentEdgeInsets is a property for UIButton, there doesn't appear to be any class method to do what you're asking.
I think you're going to have to subclass UIButton and implement a delegate to tell you when the button is pressed and update the button accordingly.
精彩评论