Best way to change the background color for an NSView

Yeah, your own answer was right. You could also use Cocoa methods: – (void)drawRect:(NSRect)dirtyRect { // set any NSColor for filling, say white: [[NSColor whiteColor] setFill]; NSRectFill(dirtyRect); [super drawRect:dirtyRect]; } In Swift: class MyView: NSView { override func draw(_ dirtyRect: NSRect) { super.draw(dirtyRect) // #1d161d NSColor(red: 0x1d/255, green: 0x16/255, blue: 0x1d/255, alpha: 1).setFill() dirtyRect.fill() } … Read more

CSS ”background-color” attribute not working on checkbox inside

A checkbox does not have background color. But to add the effect, you may wrap each checkbox with a div that has color: <div class=”evenRow”> <input type=”checkbox” /> </div> <div class=”oddRow”> <input type=”checkbox” /> </div> <div class=”evenRow”> <input type=”checkbox” /> </div> <div class=”oddRow”> <input type=”checkbox” /> </div>

CSS: Set a background color which is 50% of the width of the window

Older Browser Support If older browser support is a must, so you can’t go with multiple backgrounds or gradients, you’re probably going to want to do something like this on a spare div element: #background { position: fixed; top: 0; left: 0; width: 50%; height: 100%; background-color: pink; } Example: http://jsfiddle.net/PLfLW/1704/ The solution uses an … Read more

How to customize the background color of a UITableViewCell?

Here is the most efficient way I have come across to solve this problem, use the willDisplayCell delegate method (this takes care of the white color for the text label background as well when using cell.textLabel.text and/or cell.detailTextLabel.text): – (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { … } When this delegate method is called the … Read more

How to add a color overlay to a background image? [duplicate]

I see 2 easy options: multiple background with a translucent single gradient over image huge inset shadow gradient option: html { min-height:100%; background:linear-gradient(0deg, rgba(255, 0, 150, 0.3), rgba(255, 0, 150, 0.3)), url(http://lorempixel.com/800/600/nature/2); background-size:cover; } shadow option: html { min-height:100%; background:url(http://lorempixel.com/800/600/nature/2); background-size:cover; box-shadow:inset 0 0 0 2000px rgba(255, 0, 150, 0.3); } an old codepen of … Read more

How to get the background color code of an element in hex?

Check example link below and click on the div to get the color value in hex. var color=””; $(‘div’).click(function() { var x = $(this).css(‘backgroundColor’); hexc(x); console.log(color); }) function hexc(colorval) { var parts = colorval.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/); delete(parts[0]); for (var i = 1; i <= 3; ++i) { parts[i] = parseInt(parts[i]).toString(16); if (parts[i].length == 1) parts[i] = ‘0’ … Read more