如何使用代码模拟UIButton的物理触摸?我想要的是UIButton变为高光状态然后再回到正常状态,就像被真正的手指点击一样. 您可以通过以下方式实现: - (void)buttonTapped { [UIView animateWithDura
- (void)buttonTapped {
[UIView animateWithDuration:.5 animations:^{
[_button setHighlighted:YES];
} completion:^(BOOL finished) {
[_button sendActionsForControlEvents:UIControlEventTouchUpInside];
// or call the relevant method here
[_button setHighlighted:NO];
}];
}
在哪里你也可以看到hilighting动画……
