@IBAction func sizeChanged(sender: UISlider) {
let senderValue = CGFloat(sender.value)
varlabel?.font = UIFont(name: (varlabel?.font.fontName)!, size: varlabel!.font.pointSize * senderValue)
varlabel?.sizeToFit()
}
It doesn't work.
thanks
Use this code:
let senderValue = CGFloat(sender.value)
varlabel.font = UIFont(name: varlabel.font.fontName, size: senderValue)
Explantation : @angul: You are doing multiplication for each time sender value is change so it always increase current font size. Instead directly assign sender value to font size and set slider max/min value according to that.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.