Custom Font color (Dark Navy Blue) - uicolor

I'm trying to make a font the same color as a detail disclosure button (dark purple or dark navy blue).
I used the following combination [UIColor colorWithRed: 187.0/255.0f green:107.0/255.0f blue:207.0/255.0f alpha:1.0] but it is not even close. Can anyone please provide me with the right combination of red green and blue.

For color of the background of a detail disclosure button you'll want something like:
[UIColor colorWithRed: 28./255.f green:86./255.f blue:207./255.f alpha:1.0]
For the font color of a standard UIButton:
[UIColor colorWithRed: 38./255.f green:60./255.f blue:113./255.f alpha:1.0]

Something like this: [UIColor colorWithRed: 0f green:0f blue:0.5f alpha:1.0] should be closer.
If you want other colors, use a color chart like this one on Wikipedia, and just convert the percentages to values between 0 and 1 (e.g. 30% = 0.3)

Related

Why the webview has the gray background and smaller than the UIWebVIew

here is my code ,the amazon web page is smaller than the webview , and has a gray background
self.webView = [[UIWebView alloc]initWithFrame:CGRectMake(0,0, self.view.frame.size.width, self.view.frame.size.height)];
because UIWebView has extra space for status bar. you can disable status bar and extra space will hide.
in case status bar use this code to hide space:
[self.webView.scrollView setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentNever];
gray color is UIWebView default background color, you can change it:
self.webView.backgroundColor = [UIColor redColor];

How do I change the alpha of an NSBezierpath filled with an image?

Note: this is on OSX NOT iOs...
NSColor has a neat helper method called "colorWithPatternImage" that allows you to treat any image as a "fill" on, for instance, an NSBezierPath.
I would like to use this to create multiple overlapping squares that contain images whose opacity I can change.
The trouble is the following:
// ok - solid white
NSColor *fillColor = [NSColor whiteColor];
// ok - same as above
fillColor = [[NSColor whiteColor] colorWithAlphaComponent:1.0];
// ok - alpha of 50% (light grey)
fillColor = [[NSColor whiteColor] colorWithAlphaComponent:0.5];
// ok - fills with content of NSImage backgroundImage
fillColor = [NSColor colorWithPatternImage:backgroundImage];
// ok - same as above
fillColor = [[NSColor colorWithPatternImage:backgroundImage] colorWithAlphaComponent:1.0];
// FAILS! - any value less than 1.0 acts like alpha is 0.0
fillColor = [[NSColor colorWithPatternImage:backgroundImage] colorWithAlphaComponent:0.9];
Any thoughts on how to accomplish this? I did try first re-drawing the NSImage with an alpha and then using it as a "patternImage." While that does properly apply the alpha to the image itself, it does nothing to the path, so you end up with a "dimmed" but opaque image.
What am I missing?

Drawing color content of NSColorWell to an NSTextView

Thanks again for the help -
What's the best way to insert a 60x60 pixel square representation of a color displayed in a colorWell into a textView? I know how to reference the values of the displayed color.
Again. thanks.
-paul.
This action works using the colorWell as the sender. It doesn't work when I add it to a button initialized action:
NSColor *wellColor;
wellColor = [colorWell color];
float
red, green, blue;
red = [wellColor redComponent];
green = [wellColor greenComponent];
blue = [wellColor blueComponent];
[colorWell setColor:wellColor];
[colorWell setColor:[NSColor colorWithCalibratedRed:red green:green blue:blue alpha:1.0]];
wellColor = [colorWell color];
NSRect r = NSMakeRect(190, 130, 100, 100);
NSBezierPath *bp = [NSBezierPath bezierPathWithRect:r];
NSColor *color = wellColor;
[color set];
[bp fill];
The simplest way is to use NSTextAttachment and attach it as an image (drawing a solid-color-filled image is a simple task you can learn about with the basic drawing documentation). Otherwise, you'll have to get into subclassing and customizing parts of the text system to make room for and draw the color there yourself.

UIColor always gives white when settings blue

I'm trying to set the background color of a UIImageView with this (It should return some green-ish color):
cell.background.backgroundColor = [UIColor colorWithRed:50 green:200 blue:50 alpha:1];
But for some reason this is only giving me a white color, it seems that whenever I set the blue it turns back to white, when I do this, it returns me yellow, which is normal:
cell.background.backgroundColor = [UIColor colorWithRed:50 green:200 blue:0 alpha:1];
Ok, I didn't realize UIColor requires a float from 0 - 1, not from 0 - 255, this works:
cell.background.backgroundColor = [UIColor colorWithRed:240.0f/255.0f green:245.0f/255.0f blue:254.0f/255.0f alpha:1];

UINavigationBar with image and default gradient background with iOS5

I'm attempting to use the new [UINavigationBar appearance] functionality in iOS5 to add a logo image to the UINavigationBars in my application. Primarily, I'd like to keep the default gradient, but center a transparent png in the NavBar. The logo image is roughly 120 pixels wide (240 pixels#2x).
I have first attempted this by setting the background image. The default behavior for setBackgroundImage:forBarMetrics: appears to be to tile the image, and all transparent parts show the default navbar background color, black. I can also set the background color via the appearance modifier, and get a flat color background, but I'd really like to get the original gradient behavior without maintaining a separate image resource for it. It also makes it easier to adjust in code, since I can adjust the tint there, rather than re-generating a new image if I decide to change it.
What I'm trying to use:
UIImage *logoImage = [UIImage imageNamed:#"logoImage"];
[[UINavigationBar appearance] setBackgroundImage:logoImage forBarMetrics:UIBarMetricsDefault];
You can do this two ways. If you want to always have the image in the navigation bar, then create an image view and set it as a subview of the navigation bar:
[self setLogoImageView:[[UIImageView alloc] init]];
[logoImageView setImage:[UIImage imageNamed:#"logo.png"]];
[logoImageView setContentMode:UIViewContentModeScaleAspectFit];
CGRect navFrame = [[navController navigationBar] frame];
float imageViewHeight = navFrame.size.height - 9;
float x_pos = navFrame.origin.x + navFrame.size.width/2 - 111/2;
float y_pos = navFrame.size.height/2 - imageViewHeight/2.0;
CGRect logoFrame = CGRectMake(x_pos, y_pos, 111, imageViewHeight);
[logoImageView setFrame:logoFrame];
[[[self navigationController] navigationBar] addSubview:logoImageView];
If you only want to display the logo in a certain view, then set the view's navigation item:
[logoImageView setAutoresizingMask:UIViewAutoresizingFlexibleHeight];
[[self navigationItem] setTitleView:logoImageView];

Resources