iphone - 如何强制 iOS 立即更改背景颜色?

标签 iphone xcode ios animation

有没有办法立即改变窗口的背景颜色?

我需要一个闪烁的背景,即每隔一秒闪烁一次红色/绿色。如我所见,背景颜色不会立即改变,只有在功能离开时才会改变。

有没有办法强制系统改变它并立即重绘窗口背景?

最佳答案

- (void)viewDidLoad 
{
    [super viewDidLoad];
    flag = YES;
    NSTimer *mTimer = [NSTimer scheduledTimerWithTimeInterval:.5
                                                       target:self 
                                                     selector:@selector(changeColor)
                                                     userInfo:nil
                                                      repeats:YES];  
}

- (void)changeColor
{
    if (flag == YES)
    {
        self.view.backgroundColor = [UIColor redColor];
        flag = NO;
        return;
    }
    self.view.backgroundColor = [UIColor blueColor];
    flag = YES;

}

关于iphone - 如何强制 iOS 立即更改背景颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6290338/

相关文章:

ios - 在单个按钮单击中隐藏多个 UIButton

iPhone 不显示多个背景?

iphone - 默认键盘出现在 iPhone 而不是我的自定义键盘

ios - 使用最少的行数设置最大标签宽度

iphone - 搜索栏和表格 View 在横向模式下不适合屏幕

ios - Cordova XCode 构建 iOS 抛出 clang : error: unable to execute command: Segmentation fault: 11

ios - 如果用户拥有没有 watch 扩展的 Apple Watch,如何在 iOS 应用程序中进行跟踪?

iphone/ipad 标准 twitter oauth 模块?

Xcode 在特定项目上崩溃

ios - UIScrollView 弹到顶部或底部