Swift UIColor Extension – Create using RGB Values (Not %)
Read OriginalThis article discusses a common pitfall in iOS development where developers mistakenly pass raw RGB values (0-255) to UIColor's initializer, which expects values between 0.0 and 1.0. The author shares a simple Swift extension that adds a static method to UIColor, allowing RGB values to be used directly by dividing them by 255.0 internally. This is a practical tip for iOS developers working with color palettes in code, helping avoid a frequent error and keeping color definitions centralized.
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