3

如何为 UIButton 的不同状态设置不同的 imageEdgeInsets ?例如

    // 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];

有人知道吗?谢谢

4

0 回答 0