Skip to main content
edited tags
Link
Naresh
  • 18.1k
  • 7
  • 119
  • 120
deleted 646 characters in body
Source Link
Jay
  • 9.6k
  • 7
  • 36
  • 45

label.font.pointSize is read-only, so I'm not sure how to change it.

Update

override func viewDidLoad() {
    super.viewDidLoad()
    println("font size before: \(label.font.pointSize)")
    label.font = UIFont(name: label.font.fontName, size: 10.0)
    println("font size after: \(label.font.pointSize)")
    label.setNeedsDisplay()
}

@IBAction func tap(sender : AnyObject) {
    println("Button tapped")
    println("tap() font size: \(label.font.pointSize)")
}

Output:

font size before: 2.0
UILabel font size after: 10.0
Button tapped
tap() font size: 17.0

The font never draws at anything other than 17.0 points.

label.font.pointSize is read-only, so I'm not sure how to change it.

Update

override func viewDidLoad() {
    super.viewDidLoad()
    println("font size before: \(label.font.pointSize)")
    label.font = UIFont(name: label.font.fontName, size: 10.0)
    println("font size after: \(label.font.pointSize)")
    label.setNeedsDisplay()
}

@IBAction func tap(sender : AnyObject) {
    println("Button tapped")
    println("tap() font size: \(label.font.pointSize)")
}

Output:

font size before: 2.0
UILabel font size after: 10.0
Button tapped
tap() font size: 17.0

The font never draws at anything other than 17.0 points.

label.font.pointSize is read-only, so I'm not sure how to change it.

added 638 characters in body
Source Link
Jay
  • 9.6k
  • 7
  • 36
  • 45

label.font.pointSize is read-only, so I'm not sure how to change it.

Update

override func viewDidLoad() {
    super.viewDidLoad()
    println("font size before: \(label.font.pointSize)")
    label.font = UIFont(name: label.font.fontName, size: 10.0)
    println("font size after: \(label.font.pointSize)")
    label.setNeedsDisplay()
}

@IBAction func tap(sender : AnyObject) {
    println("Button tapped")
    println("tap() font size: \(label.font.pointSize)")
}

Output:

font size before: 2.0
UILabel font size after: 10.0
Button tapped
tap() font size: 17.0

The font never draws at anything other than 17.0 points.

label.font.pointSize is read-only, so I'm not sure how to change it.

label.font.pointSize is read-only, so I'm not sure how to change it.

Update

override func viewDidLoad() {
    super.viewDidLoad()
    println("font size before: \(label.font.pointSize)")
    label.font = UIFont(name: label.font.fontName, size: 10.0)
    println("font size after: \(label.font.pointSize)")
    label.setNeedsDisplay()
}

@IBAction func tap(sender : AnyObject) {
    println("Button tapped")
    println("tap() font size: \(label.font.pointSize)")
}

Output:

font size before: 2.0
UILabel font size after: 10.0
Button tapped
tap() font size: 17.0

The font never draws at anything other than 17.0 points.

Source Link
Jay
  • 9.6k
  • 7
  • 36
  • 45
Loading