我正在使用 setBackgroundImage:forState: 来更新 UIButton 的背景。背景仅在几秒钟后更新。显然这里有一些刷新周期在起作用,但我无法确切地找到问题所在。我尝试使用 setNeedsRefresh 和 setNeedsDisplay 但没有任何结果。
如何立即更改 UIButton 背景?
谢谢
最佳答案
当您尝试在后台线程(例如在委托(delegate)回调中)执行 UIKit 操作时,通常会导致这样的奇怪延迟。试试这个:
dispatch_async(dispatch_get_main_queue(), ^{
// set your button background here
});
关于iphone - 更新 UIButton 背景时的延迟,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10702156/