Rocky Pulley
Rocky Pulley

Reputation: 23301

How do I use NSFont in swift?

I've tried NSFont() but it says NSFont is undefined.

var fnt = NSFont(name: "Monaco", size: 12)

I have tried "import AppKit" but it says AppKit is not a valid module either.

Upvotes: 3

Views: 4735

Answers (1)

Mick MacCallum
Mick MacCallum

Reputation: 130193

You're on iOS. You should be using UIFont instead of NSFont.

let font = UIFont(name: "Monaco", size: 12.0)

You can't import AppKit either because it's an OS X framework. UIKit is the framework you should be using.

Upvotes: 13

Related Questions