gpt4 book ai didi

uibutton - 如何防止UIButton在更新标题时闪烁

转载 作者:行者123 更新时间:2023-12-02 12:08:19 26 4
gpt4 key购买 nike

当我在 UIButton 上调用 setTitle 时,按钮在 iOS 7 中闪烁。我尝试设置 myButton.highlighted = NO,但这并没有阻止按钮闪烁。

[myButton setTitle:[[NSUserDefaults standardUserDefaults] stringForKey:@"elapsedLabelKey"] forState:UIControlStateNormal];

myButton.highlighted = NO;

以下是我设置更新标题的计时器的方法:

- (void)actionTimer {
if (myTimer == nil) {

myTimer = [NSTimer scheduledTimerWithTimeInterval: 1.0
target: self
selector: @selector(showActivity)
userInfo: nil
repeats: YES];
}
}

这是实际更新标题的方法:

- (void)showActivity {

NSString *sym = [[NSLocale currentLocale] objectForKey:NSLocaleCurrencySymbol];

if (pauseInterval == nil) {

// Update clock
seconds = [[NSDate date] timeIntervalSinceDate:startInterval] - breakTime;

// Update total earned
secRate = rate.value / 60 / 60;
total = secRate * seconds;
[totalLabel setTitle:[NSString stringWithFormat:@"%@%.4f",sym,total] forState:UIControlStateNormal];

days = seconds / (60 * 60 * 24);
seconds -= days * (60 * 60 * 24);
int hours = seconds / (60 * 60);
fhours = (float)seconds / (60.0 * 60.0);
seconds -= hours * (60 * 60);
int minutes = seconds / 60;
seconds -= minutes * 60;

// Update the timer clock
[elapsed setTitle:[NSString stringWithFormat:@"%.2i:%.2i:%.2i:%.2i",days,hours,minutes,seconds] forState:UIControlStateNormal];
}
}

最佳答案

将按钮类型设置为UIButtonTypeCustom,它将停止闪烁

关于uibutton - 如何防止UIButton在更新标题时闪烁,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19371522/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com