문제

나는 알파 속성이있는 간단한 uibutton을 가지고 있으며 1.0F에서 0.0F로 애니메이션 한 다음 1.0F로 돌아갑니다. 이것은 기본적으로 터치 다운에 응답합니다.

또한, 내가 호출하는 루틴이 메인 스레드에 있지 않은 경우 특별해야 할 일이 있습니까 (Threadpool에서 Async Delegate가 호출)?

카니레이션을 사용해야합니까?

감사!

도움이 되었습니까?

해결책

누군가가 모노 방식으로 파이프를하지 않는 한, 나는 다음을 사용한다고 말한다.

- (void) pulseButton {
    button.alpha = 0.0;
    [UIView beginAnimations:nil context:button]; {
        [UIView setAnimationDelegate:self];
        [UIView setAnimationDidStopSelector:@selector(makeVisibleAgain:finished:context:)];
        [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
        [UIView setAnimationDuration:0.50];
        button.alpha = 0.0;
    } [UIView commitAnimations];
}
- (void)makeVisibleAgain:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context
{
    UIButton *button = ((UIButton *) context);
    [UIView beginAnimations:nil context:nil]; {
        [UIView setAnimationDelegate:nil];
        [UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
        [UIView setAnimationDuration:0.5];
        button.alpha = 1.0;
    } [UIView commitAnimations];

}

다른 팁

iPhone 코드 게시물에 감사드립니다.

두 번째 대답은 글로벌 변수를 사용하고 콜백의 매개 변수를 건너 뜁니다. 다음은 첫 번째 답변을 바탕으로 오늘 알아 낸 것입니다.

private void BeginPulse (Button button)
{
    UIView.BeginAnimations (button+"fadeIn", button.Handle);
    UIView.SetAnimationDelegate (this);
    UIView.SetAnimationDidStopSelector (new MonoTouch.ObjCRuntime.Selector ("makeVisibleAgain:finished:context:"));
    UIView.SetAnimationCurve(UIViewAnimationCurve.EaseOut);
    UIView.SetAnimationDuration (0.5);
     button.Alpha = 0.25f;
    UIView.CommitAnimations ();
}

[Export ("makeVisibleAgain:finished:context:")]
private void EndPulse (NSString animationId, NSNumber finished, UIButton button)
{
    UIView.BeginAnimations (null, System.IntPtr.Zero);
    UIView.SetAnimationDelegate (this);
    UIView.SetAnimationCurve (UIViewAnimationCurve.EaseIn);
    UIView.SetAnimationDuration (0.5);
    button.Alpha = 1;
    UIView.CommitAnimations();
}

이것은 매우 간단합니다.

UIView button;

public void fadeButtonInAndOut()
{
    UIView.BeginAnimations("fadeOut");
    UIView.SetAnimationDelegate(this);
    UIView.SetAnimationDidStopSelector(new Selector("fadeOutDidFinish"));
    UIView.SetAnimationDuration(0.5f);
    button.Alpha = 0.0f;
    UIView.CommitAnimations();
}

[Export("fadeOutDidFinish")]
public void FadeOutDidFinish()
{
    UIView.BeginAnimations("fadeIn");
    UIView.SetAnimationDuration(0.5f);
    button.Alpha = 1.0f;
    UIView.CommitAnimations();
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top