Objective c pagecontrol background color - objective-c

I have a scrollview with a pagecontrol, when i change her color, my pagecontrol dissapear.
UIColor *col = [UIColor colorWithRed:14.5 green:35.6 blue:72.9 alpha:1];
self.pageControl.backgroundColor = col;

The RGB values are supposed to be between 0 and 1. (See the docs). So you're setting the background color to fully opaque white here.

UIColor *col = [UIColor colorWithRed:14.5 green:35.6 blue:72.9 alpha:1];
If you have the RGB ASCII values 0 to 255
you can specify it as
UIColor *col = [UIColor colorWithRed:(255/255) green:(0/255) blue:(0/255) alpha:1]; // This represent Red color

Related

How to set BarChartView barColor?

This is the UI Picture
I don't know how to set a lightgray color
I try to use
self.chartView.drawGridBackgroundEnabled = YES;
self.chartView.gridBackgroundColor = [UIColor grayColor];
But the effect is not what I want
You have to enable BarShadow Property as mention below:
_barChartView.drawBarShadowEnabled = YES;
By default its showing GrayColor for customize Shadow Color you have to set shadow color in BarChartDataSet like below :
BarChartDataSet *set1 = [[BarChartDataSet alloc] initWithValues:Values];
set1.barShadowColor = [UIColor lightGrayColor]; // Set your custom color here
Hope this will help you to show your Custom color in bar shadow.
You can use
UIColor *color = ...;
color = [color colorWithAlphaComponent:0.5f];
OR You can try with RGB values.
[UIColor colorWithRed:(160/255.0) green:(97/255.0) blue:(5/255.0) alpha:1]

label text in ios with more brigtness

i m creating an image gallery with label on top of it where the label background is opaque.i was successful in placing the text above the label.the problem is textcolor is not bright enough.my text color is white..but it lacking the brightness which is required could u guys help me out below is the code.
label=[[UILabel alloc]init];
label.frame = CGRectMake(column*248, row*175+415, 242, 70);
label.text=[story objectAtIndex:i];
label.font=[UIFont boldSystemFontOfSize:21];
label.alpha=0.5;
label.backgroundColor=[UIColor blackColor];
//label.backgroundColor=[UIColor clearColor];
label.textColor=[UIColor whiteColor];
label.textAlignment=UITextAlignmentLeft;
label.numberOfLines=2;
[view1 addSubview:label];
Your alpha value for the entire label is 0.5. This also dampens the font color. You could simply set the background of the label to a color with alpha value 0.5, the text should still be alpha 1.0 then.
label.alpha = 1.0; // is already the default
label.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];

Change background color with a variable iOS

I want to change the background color of my label with a variable how can I do that ?
This is my code but I'd like to have a variable instead of 'redColor'
[publisherLabel setBackgroundColor:[UIColor redColor]];
Variable with color from an RGBA value.
UIColor *myColor = [UIColor colorWithRed:100.0/255.0 green:101.0/255.0 blue:102.0/255.0 alpha:1.0]];
You can also use HEX if you want:
#define HEXCOLOR(c) [UIColor colorWithRed:((c>>24)&0xFF)/255.0
green:((c>>16)&0xFF)/255.0
blue:((c>>8)&0xFF)/255.0
alpha:((c)&0xFF)/255.0];
// usage:
UIColor* c = HEXCOLOR(0xff00ffff);

Why is my CGGradient not working with a preset UIColor?

I have this working code:
NSMutableArray *shadowColors = [NSMutableArray arrayWithCapacity:2];
color = [UIColor colorWithRed:0 green:0 blue:0 alpha:1]; // Declaration using components
[shadowColors addObject:(id)[color CGColor]];
color = [UIColor colorWithRed:1 green:1 blue:1 alpha:0.0]; // Declaration using components
[shadowColors addObject:(id)[color CGColor]];
CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB();
CGGradientRef gradient = CGGradientCreateWithColors(space, (CFArrayRef)shadowColors, NULL);
CGColorSpaceRelease(space);
CGFloat sw = 10.0; // shadow width
CGPoint top1 = CGPointMake(x, y+width/2.0);
CGPoint top2 = CGPointMake(x + sw, y+width/2.0);
CGPoint side1 = CGPointMake(x+width/2.0, y);
CGPoint side2 = CGPointMake(x+width/2.0, y+sw);
CGContextDrawLinearGradient(c, gradient, top1, top2, 0);
CGContextDrawLinearGradient(c, gradient, side1, side2, 0);
CGGradientRelease(gradient);
The color declarations are the part I'm interested in, lines 2 and 4. When I declare them as shown, they work just fine, but if I replace those two lines with the equivalent (I thought, at least) [UIColor blackColor] and [UIColor clearColor] then my gradients disappear. The colors I use don't make any difference, I can use greenColor and redColor and they still don't work.
Am I missing something or is this a bug in Apple's frameworks?
The code that doesn't work. And this is just the first section, everything else is the same.
NSMutableArray *shadowColors = [NSMutableArray arrayWithCapacity:2];
color = [UIColor blackColor];
[shadowColors addObject:(id)[color CGColor]];
color = [UIColor clearColor];
[shadowColors addObject:(id)[color CGColor]];
The code looks fine to me. blackColor and clearColor are probably both in a white color space, but the documentation says CGGradientCreateWithColors will convert the colors to the color space you pass in, so that shouldn't matter.
The only thing I can think of would be to try passing NULL for the color space, letting the gradient convert the colors to Generic RGB instead of Device RGB. This may work, but shouldn't make a difference—as far as I can see, it should work either way.
I suggest filing a bug.

UILabel sizeWithFont: problem. Clipping italic text

I have created a UILabel that displays a single large character. Even with clipsToBounds = NO; I still get clipping.
See link: http://img341.imageshack.us/img341/5310/screenshot20100814at243.png
I used the following code:
CGSize fBounds = [myLabel.text sizeWithFont:cFont];
To get what should be the bounding rectangle of the font. And the label is drawn with:
myLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 20, 280, 300)];
myLabel.clipsToBounds = NO;
myLabel.numberOfLines = 1;
myLabel.textAlignment = UITextAlignmentCenter;
myLabel.adjustsFontSizeToFitWidth = YES;
myLabel.minimumFontSize = 10;
myLabel.text = #"A";
myLabel.font = [UIFont fontWithName:#"CourierNewPSMT" size:300];
myLabel.textColor = [UIColor blackColor];
myLabel.backgroundColor = [UIColor colorWithRed:1 green:.5 blue:0 alpha:.5];
In the image below, the size returned from sizeWithFont is rendered by the semi-transparent blue rectangle overlay. As you can see, with an italic font (in this case Verdana-BoldItalic), the character extends past what sizeWithFont returns. Further, the UILabel's frame (the orange color) also clips the character. Thoughts? Maybe I could override some text drawing routine. Also, not sure if this is the same problem as here:
UIButton.titleLabel clipping text problem
Use attributed text + indent...
Looks like this is an apple problem. Ended up doing custom drawing with CoreText.