Two colors for UILabel TEXT

you can set text color with pattern image like bellow.. [yourLable setTextColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@”yourImageName”]]]; and also set different color with this bellow code.. please check tutorial with detail mate.. NSString *test = @”Hello. That is a test attributed string.”; CFStringRef string = (CFStringRef) test; CFMutableAttributedStringRef attrString = CFAttributedStringCreateMutable(kCFAllocatorDefault, 0); CFAttributedStringReplaceString (attrString,CFRangeMake(0, 0), string); /* Note: … Read more

Replace a particular color inside an image with another color

You have to iterate through each pixel in the image and take its rgb values Check its rgb values matches your fromColor rgb values, if yes change the pixel value to your toColor rgb values.If not, just leave that pixel and go to next one.. Wrote a function from memory..errors possible..correct yourself -(UIImage*)changeColor:(UIImage*)myImage fromColor:(UIColor*)fromColor toColor:(UIColor*)toColor{ … Read more

Android Button Drawable Tint

You can achieve coloring the drawableleft on a button with this method: Step 1: Create a drawable resource file with bitmap as parent element as shown below and name it as ic_action_landscape.xml under the drawable folder <?xml version=”1.0″ encoding=”utf-8″?> <bitmap xmlns:android=”http://schemas.android.com/apk/res/android” android:src=”https://stackoverflow.com/questions/30938620/@android:drawable/ic_btn_speak_now” android:tint=”@color/white” /> Step 2: Create your Button control in your layout as below … Read more

How can I change the color of a UIImage? [duplicate]

The accepted answer is correct, but there is a much more easy way for UIImageView: Obj-C: UIImage *image = [UIImage imageNamed:@”foo.png”]; theImageView.image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; [theImageView setTintColor:[UIColor redColor]]; Swift 2: let theImageView = UIImageView(image: UIImage(named:”foo”)!.imageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate)) theImageView.tintColor = UIColor.redColor() Swift 3: let theImageView = UIImageView(image: UIImage(named:”foo”)!.withRenderingMode(.alwaysTemplate)) theImageView.tintColor = UIColor.red

Making RGB color in Xcode

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 … Read more

Storing UIColor object in Core Data

Your attribute should be of the type Transformable. The default value transformer (NSKeyedUnarchiveFromDataTransformerName) can transform any object that conforms to NSCoding. Mark the attribute as type “Tranformable”. Optional: Set the Value Transformer Name to “NSKeyedUnarchiveFromDataTransformerName”. If you do not, it will default to this anyway. You do not have to do anything else. Keep in … Read more

How to convert HEX RGB color codes to UIColor?

In some code of mine, I use 2 different functions: void SKScanHexColor(NSString * hexString, float * red, float * green, float * blue, float * alpha) { NSString *cleanString = [hexString stringByReplacingOccurrencesOfString:@”#” withString:@””]; if([cleanString length] == 3) { cleanString = [NSString stringWithFormat:@”%@%@%@%@%@%@”, [cleanString substringWithRange:NSMakeRange(0, 1)],[cleanString substringWithRange:NSMakeRange(0, 1)], [cleanString substringWithRange:NSMakeRange(1, 1)],[cleanString substringWithRange:NSMakeRange(1, 1)], [cleanString substringWithRange:NSMakeRange(2, 1)],[cleanString … Read more