set color of any UI in RGB format [duplicate] - objective-c

This question already has answers here:
Making RGB color in Xcode
(5 answers)
Closed 5 years ago.
When I am setting color of any UI like text field place holder color or Slider maximum and minimum tint color in RGB format, It is not showing any color but just like a clear color. When I am changing red color of RGB to 0 it is showing mix color of green and blue. But as I increases value of Red in RGB up to 1 it is going to be faint and at 1, it is invisible. my code is
To set slider color
[_sliderSpeed setMaximumTrackTintColor:[UIColor colorWithRed:181 green:217 blue:255 alpha:1]];
To set text field placeholder color
NSAttributedString *pin = [[NSAttributedString alloc] initWithString:#"Add pin" attributes:#{ NSForegroundColorAttributeName : [UIColor colorWithRed:0 green:103 blue:169 alpha:1] }];
self.pin.attributedPlaceholder = pin;
Please help me.

It should be like this
[_sliderSpeed setMaximumTrackTintColor:[UIColor colorWithRed:(181/255.0) green:(217/255.0) blue:(255/255.0) alpha:1] ;//set your color here
For Ref:
https://stackoverflow.com/a/10379026

Related

Losing colours when using drawInRect withAttributes [UIColor blackColor]

I've replaced a deprecated usage of drawInRect:withFont, but the side effect is that I can no longer see some of the colours in a colour bar in my app. Green is replaced with black (except with the first box in the bar, because the yearText hasn't been drawn yet), yellow and red are replaced by white.
Here's the code I use to add colour to the bar boxes:
CGFloat *yearColor = (CGFloat[]){0.5, 0.5, 0.5, 1.0};
CGContextSetFillColor(ctx, yearColor);
CGRect yearRect = CGRectMake(xOffset+1,
yOffset+kScoreBoxHeight-2,
kScoreBoxWidth+50,
kScoreBoxHeight);
Here's the code I'm replacing the deprecated drawInRect with
[theYear drawInRect:yearRect
withAttributes:#{
NSFontAttributeName:
[UIFont fontWithName:#"PFTempestaFiveCompressed" size:8.0],
NSForegroundColorAttributeName: [UIColor darkGrayColor ]
}];
Here's the original drawInRect method using withFont. I'm not specifying any font colour, relying on the default, black.
[theYear drawInRect:yearRect withFont:[UIFont
fontWithName:#"PFTempestaFiveCompressed" size:8.0]];
The problem seems to occur with dark colours (black, grey). Here's an example that works with brown.
[theYear drawInRect:yearRect
withAttributes:#{NSFontAttributeName: yearFont,
NSForegroundColorAttributeName: [UIColor brownColor]}];

AVMutableVideoCompositionInstruction background Color using UIImage?

I want to change the background color for AVMutableVideoCompositionInstruction which is working fine.But in when I am using UIImage for Color Pattern its not Working ??? Please Help...here is code Image Using.also I am giving is BackgroundColor White but its not Showing it White.
here is my code I am using:
AVMutableVideoCompositionInstruction *MainInstruction = [AVMutableVideoCompositionInstruction videoCompositionInstruction];
MainInstruction.timeRange = CMTimeRangeMake(kCMTimeZero, asset.duration);
MainInstruction.layerInstructions = layerInstructionsArr;
UIColor *bgBlurrcolor =[UIColor colorWithPatternImage:[UIImage imageNamed:#"aa.png"]];
MainInstruction.backgroundColor = bgBlurrcolor.CGColor;
Check these links
Only solid BGRA colors are supported; patterns and other supported colors are ignored. If the rendered pixel buffer does not have alpha, the alpha value of the background color is ignored.
If the background color is NULL, the video compositor uses a default background color of opaque black.
https://developer.apple.com/reference/avfoundation/avvideocompositioninstruction?language=objc
https://developer.apple.com/reference/avfoundation/avvideocompositioninstruction/1389384-backgroundcolor?language=objc

How to color from yellow to Red periodically

I am looking for some help in how to change the color of a textField from Yellow to Red by calculation?
Ex: If my WarningDays = 5, then when 5 days are left for expiration, I need to display the text in Yellow and keep changing the color closer to red where when 1 day is left, the text would be displayed in Red.
Any help would be appreciated. I am very new to UI programming.
Something like this should work:
int expirationDays = 5;
float yellowComponent = expirationDays/5 * 255.0;
UIColor *yellowToRedColor = [UIColor colorWithRed:255.0/255.0 green:yellowComponent/255.0 blue:0.0/255.0 alpha:1];

How to Fix text of UILabel word Character cut on Bottom side [duplicate]

This question already has answers here:
UILabel cuts off custom font. How do I dynamically adjust UILabel height based on custom font selected?
(3 answers)
Closed 6 years ago.
my following Code is
NSMutableParagraphStyle *body1stParagraph = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
body1stParagraph.alignment = NSTextAlignmentCenter;
body1stParagraph.minimumLineHeight = _font_Size;
attrs = #{ NSFontAttributeName : [UIFont fontWithName:font_name size:Font_size],
NSParagraphStyleAttributeName : body1stParagraph,
NSAttachmentAttributeName: textAttachment};
and this Dictionary add on Attributed String
[attributeString addAttributes:attrs range:lineRange];
but text of label is Cut
this may solve your problem -
yourLabel.sizeToFit()

Changing the color of an SKSpriteNode image?

I was wondering if there was a way to change the color of an SKSpriteNode programmatically?? Say I have a texture for an SKSpriteNode that is a box that has a black outline and a white fill color. How would I be able to change the white fill color to a different color programmatically?? (I was thinking maybe a custom method that searched a texture for white pixels and then replace the pixels with a different color) I don't even know if this is possible.
You can set a color to SKSpriteNode and then use colorBlendFactor, here is an example:
image.color = [UIColor greenColor];
image.colorBlendFactor = 0.5;