Andrew Bancroft 1/24/2018

Swift 4 Upgrade Error: ‘init(colorLiteralRed:green:blue:alpha:)’ is unavailable

Read Original

This article addresses a common compiler error encountered when upgrading projects to Swift 4: 'init(colorLiteralRed:green:blue:alpha:)' is unavailable. It explains that this initializer is only meant for color literals and provides a straightforward fix: replace 'colorLiteralRed:' with 'red:' in the UIColor initializer. The article includes a code example showing the correct usage with division by 255 for RGB values. It is a concise technical guide aimed at iOS developers working with Swift 4, focusing on a specific API change and best practices for color initialization.

Swift 4 Upgrade Error: ‘init(colorLiteralRed:green:blue:alpha:)’ is unavailable

Comments

No comments yet

Be the first to share your thoughts!

Browser Extension

Get instant access to AllDevBlogs from your browser

Top of the Week

No top articles yet