在iOS 5中为UIButton的不同状态设置不同的imageEdgeInsets

时间:2012-07-03 09:21:25

标签: image ios5 uibutton

如何为UIButton的不同状态设置不同的imageEdgeInsets? e.g

    // For UIControlStateHighlighted state
UIEdgeInsets checkedImageInsets = UIEdgeInsetsMake(-1, -10, -90, -50);
cell.firstElementButton.imageEdgeInsets = checkedImageInsets;
[cell.firstElementButton setImage:[UIImage imageNamed:CHECKBOX_CHECKED_IMAGE] forState:UIControlStateHighlighted];

// For UIControlStateNormal state
UIEdgeInsets uncheckedImageInsets = UIEdgeInsetsMake(-1, -50, -10, -50);
cell.firstElementButton.imageEdgeInsets = uncheckedImageInsets;
[cell.firstElementButton setImage:[UIImage imageNamed:CHECKBOX_UNCHECKED_IMAGE] forState:UIControlStateNormal];

有人知道吗?感谢

0 个答案:

没有答案