swift if button is pressed run function programmatically code example Example: button click programmatically swift button.sendActions(for: .touchUpInside)