Swift UIColor Extension – Create using RGB Values (Not %)
Read OriginalThis article discusses a common pitfall in iOS development where UIColor's initializer expects RGB values as percentages (0.0 to 1.0) rather than the more intuitive 0-255 range. The author shares a personal experience of making this mistake and provides a Swift extension that adds a static method to UIColor, allowing developers to pass RGB values directly (0-255) and automatically dividing by 255.0. The extension simplifies color management in code and helps avoid a frequent error for both new and experienced iOS developers. The article is a practical, code-focused tutorial relevant to iOS programming and software development.
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