設定影象

迅速

button.setImage(UIImage(named:"test-image"), forState: .normal)

目標 C.

[self.button setImage:[UIImage imageNamed:@"test-image"] forState:UIControlStateNormal];

多個控制狀態

你還可以為多個 UIControlStates 設定影象,例如為 SelectedHighlighted 狀態設定相同的影象:

迅速

button.setImage(UIImage(named:"test-image"), forState:[.selected, .highlighted])

目標 C.

[self.button setImage:[UIImage imageNamed:@"test-image"] forState:UIControlStateSelected|UIControlStateHighlighted];