問題描述
點擊cell的時候,讓cell里面的透明度降低,松開手指透明度恢復(fù)。
類似支付那樣
實現(xiàn)方法
重寫UIResponder的touchesBegan和touchesEnded
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
[super touchesBegan:touches withEvent:event];
[UIView animateWithDuration:0.5 animations:^{
self.topViewImg.alpha = 0.7;
self.bottomlable.alpha = 0.7;
}];
}
-(void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
[UIView animateWithDuration:0.5 animations:^{
self.topViewImg.alpha = 1;
self.bottomlable.alpha = 1;
}];
[super touchesEnded:touches withEvent:event];
}
效果圖
效果圖
拓展
因為touchesBegan和touchesEnded是uiview的父類的方法,所以所有的view都可以實現(xiàn)這種效果。
估計uibutton點擊閃動效果也是這樣實現(xiàn)的