开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜