iOS use of NSColor versus UIColor?

浪尽此生 提交于 2019-12-05 01:07:54

There is no such thing as NSColor in iOS. UIColor is what you should use.

NSColor only exists as a OSX class.

As Nate says, NSColor is OSX only. If you ran across a mention of it in the docs on NSAttributedString, it's probably documentation intended for Mac OS. Some of the docs do "bleed over" between platforms.

If you search the Xcode docs for NSAttributedString(NSStringDrawing) you'll see some UIKit additions to NSAttributedString that let you specify colors using UIColors.

It looks like the equivalent OS X application kit extensions are called NSAttributedString(NSAttributedStringKitAdditions). Gotta love the consistent naming conventions, huh?

NSColor is from AppKit and UIColor is from UIKit. UIKit was built from the ground up for iOS and AppKit came over from NeXT. As AppKit is a Mac only framework you cannot use NSColor in an iOS app.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!