0

我有 3 张图片用于设置 self.view.background 。我正在尝试什么,像 Twitter iOS APP Login UI 一样设置背景(每 5 秒随机更改背景图像。)

所有随机过程都完成了,我真正遇到的麻烦是,当我使用 UIAnimation 时,它会随机化同步模式。当它工作时,整个 UI 会按预期等待 UIAnimation 进程。

这是我的代码:(我在 viewDidLoad 方法的末尾调用此方法:

注意:另外,设置 alpha 不起作用..

-(void)startBackgroundImageChange
{

    dispatch_async(dispatch_get_main_queue(), ^{

    [UIView animateWithDuration:5.0
                          delay:0.2
                        options:UIViewAnimationOptionBeginFromCurrentState
                     animations:^{

                         [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

                         self.view.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:[self setBackgroundImage]]];

                         self.view.alpha = 1.0;

                         //here you may add any othe actions, but notice, that ALL of them will do in SINGLE step. so, we setting ONLY xx coordinate to move it horizantly first.
                     }
                     completion:^(BOOL finished){

                         //here any actions, thet must be done AFTER 1st animation is finished. If you whant to loop animations, call your function here.
                         self.view.alpha = 0.3;
                         [self startBackgroundImageChange];
                     }];

        });

}

任何帮助将不胜感激 ..

4

0 回答 0