[英]Can I keep UI elements accessable while changing background color in Xcode?
我在Xcode中有一个游戏,在白色背景上有几个UIButton。 当用户单击正确的按钮时,我将背景从白色更改为蓝绿色(动画)。 我想让用户继续单击,而背景颜色却发生了变化,但是看起来直到bg颜色动画运行完毕才可以访问按钮。 有没有办法解决它并使焦点集中在按钮上? 背景动画能否在后台发生而不依赖于游戏的其余部分?
预先感谢您对理解此问题的任何帮助。 这是我的代码:
[UIView animateWithDuration:0.3f
animations:^{
self.view.backgroundColor = [UIColor colorWithRed:0.1f green:0.15f blue:0.05f alpha:1.0f];
}
completion:^(BOOL finished){
[UIView animateWithDuration:0.3f
animations:^{
self.view.backgroundColor = [UIColor colorWithRed:1.0f green:1.0 blue:1.0 alpha:1.0f];
}
];
}
];
所有UIButton都在前面的单独方法中添加了
UIButton *btnI;
[self.view addSubview:btnI];
采用
dispatch_async(backgroundQueue, {
//change the background colour here
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.