問(wèn)題描述
點(diǎn)擊cell的時(shí)候,讓cell里面的透明度降低,松開(kāi)手指透明度恢復(fù)。
類似支付那樣
實(shí)現(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];
}
效果圖
效果圖
拓展
因?yàn)閠ouchesBegan和touchesEnded是uiview的父類的方法,所以所有的view都可以實(shí)現(xiàn)這種效果。
估計(jì)uibutton點(diǎn)擊閃動(dòng)效果也是這樣實(shí)現(xiàn)的