3 초 동안 버튼을 눌러 색상을 변경하려고합니다. 타이머가 3 초에 도달하면 색상 변경은 영구적이지만 시간이 다가 오기 전에 버튼을 놓으면 버튼이 원래 색상으로 돌아갑니다. 나는이 날 화재로 애니메이션을 위해 아래로 3 초 동안 버튼을 길게 할 필요U 버튼을 누른 상태에서 색을 변경하는 방법과 x 초 전에 풀면 색 변경을 취소하는 방법은 무엇입니까?
- (void)someMethod {
[UIView transitionWithView:self.button
duration:2.0
options:UIViewAnimationOptionCurveEaseIn
animations:^{
self.button.backgroundColor = [UIColor redColor];
}
completion:^(BOOL finished) {
NSLog(@"animation finished");
}];
}
이 fireSomeMethod
에
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc]
initWithTarget:self
action:@selector(fireSomeMethod)];
longPress.minimumPressDuration = 3.0;
[self.view addGestureRecognizer:longPress];
viewDidLoad
과 애니메이션 자체가이 소요 : 내가 지금까지 가지고하는 것은 이것이다 완료하려면 초. 원하는 동작은 longPress가 시작되면 애니메이션이 시작되고 3 초 전에 버튼을 놓으면 모든 것이 원래대로 되돌아갑니다.