iOS dark gray box active style
It's the -webkit-tap-highlight-color. Here's a little extra info for you:
http://css-infos.net/property/-webkit-tap-highlight-color
/* webkit-tap-highlight-color */
a:link { -webkit-tap-highlight-color: #aa0000; }
/* To set it to none use a totally transparent RGBA */
a:link { -webkit-tap-highlight-color: rgba(0,0,0,0); }
You can also check out the Safari Mobile developer docs to see the supported CSS properties.
remove grey background on link clicked in ios safari / chrome / firefox
Webkit has a specific style property for that: -webkit-tap-highlight-color
.
Copied from: http://davidwalsh.name/mobile-highlight-color—
/* light blue at 80% opacity */
html {
-webkit-tap-highlight-color: rgba(201, 224, 253, 0.8);
}
/* change it for a div that has a similar background-color to the light blue tap color */
.blueDiv {
-webkit-tap-highlight-color: rgba(251, 185, 250, 0.9);
}
If you want to remove the highlight completely—
.myButton {
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
Disabled UIButton not faded or grey
You can use following code:
sendButton.enabled = YES;
sendButton.alpha = 1.0;
or
sendButton.enabled = NO;
sendButton.alpha = 0.5;
iOS Safari Mobile image map - area displays box when clicked
As mentioned in iOS dark gray box active style you have to hide the tap highlight box:
img { -webkit-tap-highlight-color: rgba(0,0,0,0); }
How to change the colors of a segment in a UISegmentedControl in iOS 13?
As of iOS 13b3, there is now a selectedSegmentTintColor
on UISegmentedControl
.
To change the overall color of the segmented control use its backgroundColor
.
To change the color of the selected segment use selectedSegmentTintColor
.
To change the color/font of the unselected segment titles, use setTitleTextAttributes
with a state of .normal
/UIControlStateNormal
.
To change the color/font of the selected segment titles, use setTitleTextAttributes
with a state of .selected
/UIControlStateSelected
.
If you create a segmented control with images, if the images are created as template images, then the segmented control's tintColor
will be used to color the images. But this has a problem. If you set the tintColor
to the same color as selectedSegmentTintColor
then the image won't be visible in the selected segment. If you set the tintColor
to the same color as backgroundColor
, then the images on the unselected segments won't be visible. This means your segmented control with images must use 3 different colors for everything to be visible. Or you can use non-template images and not set the tintColor
.
Under iOS 12 or earlier, simply set the segmented control's tintColor
or rely on the app's overall tint color.
UITableView - change section header color
Hopefully this method from the UITableViewDelegate
protocol will get you started:
Objective-C:
- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView *headerView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 30)] autorelease];
if (section == integerRepresentingYourSectionOfInterest)
[headerView setBackgroundColor:[UIColor redColor]];
else
[headerView setBackgroundColor:[UIColor clearColor]];
return headerView;
}
Swift:
func tableView(_ tableView: UITableView!, viewForHeaderInSection section: Int) -> UIView!
{
let headerView = UIView(frame: CGRect(x: 0, y: 0, width: tableView.bounds.size.width, height: 30))
if (section == integerRepresentingYourSectionOfInterest) {
headerView.backgroundColor = UIColor.redColor()
} else {
headerView.backgroundColor = UIColor.clearColor()
}
return headerView
}
Updated 2017:
Swift 3:
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView?
{
let headerView = UIView(frame: CGRect(x: 0, y: 0, width: tableView.bounds.size.width, height: 30))
if (section == integerRepresentingYourSectionOfInterest) {
headerView.backgroundColor = UIColor.red
} else {
headerView.backgroundColor = UIColor.clear
}
return headerView
}
Replace [UIColor redColor]
with whichever UIColor
you would like. You may also wish to adjust the dimensions of headerView
.
Related Topics
Width: 100% with Position: Absolute
Set The Same Value to Multiple Properties (CSS)
CSS - Centering a Page - Then Making The Page 100% Height
How to Style Bootstrap Col-Lg-* Classes
CSS Variables with Background-Image Url
Transition Only for The Border on Hover, But Not for Background
2-Column CSS Responsive Layout with a Responsive Image
Update Source File When CSS Is Changed Through Chrome Developer Tools
Webkit Scrollbar CSS, Always a White Box in Corner
Stretch List Items <Li> to Fill The Width of <Ul>
What Are The Best Practices for Writing Maintainable CSS
Float a Div in Top Right Corner Without Overlapping Sibling Header
How to Use CSS Variables in Twitter-Bootstrap 4 $Theme-Colors Array
How to Style Form Drop Down Lists
Vaadin - Coloring Table Cells Based on Content