Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use NSFont in swift?

Tags:

ios

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.

like image 373
Rocky Pulley Avatar asked Jan 21 '26 10:01

Rocky Pulley


1 Answers

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.

like image 156
Mick MacCallum Avatar answered Jan 24 '26 02:01

Mick MacCallum