/ / IPHONE - зникає і зникає з UIImageView з різним часом - iphone, iphone-sdk-3.0, ipad

IPHONE - зникає і зникає з UIImageView з різними часами - iphone, iphone-sdk-3.0, ipad

Я хотів би зробити вимкнення та вихід з UIImageView, використовуючи різні часи, скажімо, використовуючи такі параметри:

  • t = 0 ... UIImageView "s альфа = 0
  • t = 0,5s ... UIImageView "s альфа = 0,7
  • t = 0,7s ... UIImageView "s alpha = 0

Чи можливо це зробити з CAAnimation чи іншим методом? Як це можна зробити?

дякую за будь-яку допомогу!

Відповіді:

3 для відповіді № 1

Вам, мабуть, варто заглянути в CAKeyframeAnimation. Це дозволить вам встановити значення для кількох часових точок.


6 для відповіді № 2
if (imgDefault.alpha == 0.0) {
CGContextRef context = UIGraphicsGetCurrentContext();
[UIView beginAnimations:nil context:context];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[UIView setAnimationDuration: 3.0];
[UIView setAnimationDelegate: self];
imgDefault.alpha = 1.0;
[UIView commitAnimations];
}
else {
CGContextRef context = UIGraphicsGetCurrentContext();
[UIView beginAnimations:nil context:context];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[UIView setAnimationDuration: 3.0];
[UIView setAnimationDelegate: self];
imgDefault.alpha = 0.0;
[UIView commitAnimations];
}

сподіваюся, це допомагає


2 для відповіді № 3

UIView має набірAnimationDidStopSelector: метод, який ви можете використовувати. Просто налаштуйте свій ефект зникнення в анімації за допомогою блоку BeginAnimations та встановіть селектор didStop на інший метод, який містить лише блок зникаючої анімації. Кожен з цих блоків анімації може мати різну тривалість анімації.

Щось на зразок цього:

    [UIView beginAnimations:next context:context];
[UIView setAnimationDuration:0.5];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(fadeOut:finished:context:)];
myView.alpha = 0.7;
[UIView commitAnimations];

-(void)fadeOut:(NSString*)animationID finished:(BOOL)finished context:(void*)context  {
[UIView beginAnimations:nil context:context];
[UIView setAnimationDuration:0.2];
myView.alpha = 0.0;
[UIView commitAnimations];
}