我们调用startTimer函数来启动计时器.当我们想要停止它时,我们调用stopTimerTest函数,但在我们调用stopTimer函数后,timerTestAction继续触发.要检查计时器条件,我们在timerActionTest中使用print和print返回nil.
var timerTest: Timer? = nil
func startTimer () {
timerTest = Timer.scheduledTimer(
timeInterval: TimeInterval(0.3),
target : self,
selector : #selector(ViewController.timerActionTest),
userInfo : nil,
repeats : true)
}
func timerActionTest() {
print(" timer condition \(timerTest)")
}
func stopTimerTest() {
timerTest.invalidate()
timerTest = nil
}
Run Code Online (Sandbox Code Playgroud) 编辑:链接的"重复"问题仅涉及计算文本矩形.我需要在标签缩放后计算实际字体大小,而不是字符串大小.
现在不推荐使用此方法:
size = [self sizeWithFont:font // 20
minFontSize:minFontSize // 14
actualFontSize:&actualFontSize // 16
forWidth:maxWidth
lineBreakMode:self.lineBreakMode];
Run Code Online (Sandbox Code Playgroud)
现在在iOS 7中缩小文本大小以适应时,如何计算UILabel的字体大小?
我需要联系,更改它并存储回来.
CNContactStore().unifiedContacts
给我一个CNContact
实例,但CNSaveRequest().update
要求CNMutableContact
.
如何将CNContact转换为CNMutableContact?
我有一个UIView
圆形的形状,我需要显示UIView
百分比值的边框颜色,如果百分比值是50%,它应该填充UIView的半边框颜色.我已经使用了UIBeizer
路径addArcWithCenter
但是我没有得到完美的解决方案.请帮帮我