添加按下去动画
This commit is contained in:
@@ -63,12 +63,18 @@
|
||||
|
||||
- (void)setHighlighted:(BOOL)highlighted {
|
||||
[super setHighlighted:highlighted];
|
||||
// 简单按压反馈:选中态不改变透明度,避免和高亮态冲突
|
||||
if (self.isSelected) {
|
||||
self.alpha = 1.0;
|
||||
} else {
|
||||
self.alpha = highlighted ? 0.2 : 1.0;
|
||||
|
||||
// 按下时整体做一个等比缩放动画,不改背景色和透明度。
|
||||
// 这样无论是纯文字键还是整块皮肤图,都有统一的“按下”视觉反馈。
|
||||
NSLog(@"来了老弟=====");
|
||||
CGFloat scale = highlighted ? 0.9 : 1.0; // 可根据手感微调 0.9~0.95
|
||||
[UIView animateWithDuration:0.08
|
||||
delay:0
|
||||
options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseOut
|
||||
animations:^{
|
||||
self.transform = CGAffineTransformMakeScale(scale, scale);
|
||||
}
|
||||
completion:nil];
|
||||
}
|
||||
|
||||
- (void)setSelected:(BOOL)selected {
|
||||
|
||||
Reference in New Issue
Block a user