Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7884947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:56:09+00:00 2026-06-03T04:56:09+00:00

I am using RGB values of a color from Photoshop and using the same

  • 0

I am using RGB values of a color from Photoshop and using the same in Xcode the values are.Color-R-160,G-97,B-5…the color in Photoshop appears yellowish but in Xcode when I used

myLabel.textColor = [UIColor colorWithRed:160 green:97 blue:5 alpha:1] ;

the color appears whitish.

Why this difference is happening?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T04:56:10+00:00Added an answer on June 3, 2026 at 4:56 am

    Objective-C

    You have to give the values between 0 and 1.0. So divide the RGB values by 255.

    myLabel.textColor= [UIColor colorWithRed:(160/255.0) green:(97/255.0) blue:(5/255.0) alpha:1] ;
    

    Update:

    You can also use this macro

    #define Rgb2UIColor(r, g, b)  [UIColor colorWithRed:((r) / 255.0) green:((g) / 255.0) blue:((b) / 255.0) alpha:1.0]
    

    and you can call in any of your class like this

     myLabel.textColor = Rgb2UIColor(160, 97, 5);
    

    Swift

    This is the normal color synax

    myLabel.textColor = UIColor(red: (160/255.0), green: (97/255.0), blue: (5/255.0), alpha: 1.0) 
    //The values should be between 0 to 1
    

    Swift is not much friendly with macros

    Complex macros are used in C and Objective-C but have no counterpart
    in Swift. Complex macros are macros that do not define constants,
    including parenthesized, function-like macros. You use complex macros
    in C and Objective-C to avoid type-checking constraints or to avoid
    retyping large amounts of boilerplate code. However, macros can make
    debugging and refactoring difficult. In Swift, you can use functions
    and generics to achieve the same results without any compromises.
    Therefore, the complex macros that are in C and Objective-C source
    files are not made available to your Swift code.

    So we use extension for this

    extension UIColor {
        convenience init(_ r: Double,_ g: Double,_ b: Double,_ a: Double) {
            self.init(red: r/255, green: g/255, blue: b/255, alpha: a)
        }
    }
    

    You can use it like

    myLabel.textColor = UIColor(160.0, 97.0, 5.0, 1.0)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get rgb color info from every pixel using imagecolorat() and I'm
In my application I read RGB pixel values from several images using fast unmanaged
I'm trying to color individual pixels in a BufferedImage (TYPE_INT_RGB) using setRGB() , but
I have a greyscale image which was created from a RGB image using farmula:
Is it possible to get the RGB color of a pixel using PIL? I'm
I am trying to get the RGB background color in IE using the following
I have created a variable using System.Windows.Media.Color. I can display the Hex value from
So I have a color picker. Users can pick colors using RGB or HSB.
I am using RGB color code for my bar to show in iphone app
I'm drawing an image using rgb pixel data. I need to set transparent background

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.