Core IOS Sample 2-2 Button Zoom动画
为 button
添加了两个事件
[button addTarget:button action:@selector(zoomButton:) forControlEvents: UIControlEventTouchDown | UIControlEventTouchDragInside | UIControlEventTouchDragEnter];
[button addTarget:button action:@selector(relaxButton:) forControlEvents: UIControlEventTouchDragExit | UIControlEventTouchCancel | UIControlEventTouchDragOutside];
对应 selector
为:
- (void)zoomButton:(UIButton *)aButton
{
[UIView animateWithDuration:0.2f
animations:^{
self.transform = CGAffineTransformMakeScale(1.1f, 1.1f);
}];
}
- (void)relaxButton:(UIButton *)aButton
{
[UIView animateWithDuration:0.2f
animations:^{
self.transform = CGAffineTransformIdentity;
}];
}