Tinting the background pinstripes of a grouped UITableView - iphone

How do I apply a tint to the background of a UITableView using the grouped style? The standard "color" used ([UIColor groupTableViewBackgroundColor]) is tinted blue; I want a green tint instead.
This uses a pattern rather than a true color. I just want to tint that pattern to match the colors I'm using elsewhere, not replace it with a solid color.

The easiest way is to make a screenshot of the default grouped tableview background and crop it so that its size is 7x1 pixels (that's enough to tile it). Adjust the tint color (hue, saturation, brightness) in your favorite image editor and use the resulting image as a pattern color via +colorWithPatternImage:, e.g.:
myTableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"GreenStripes.png"]];

You could probably do this somehow with coregraphics by drawing the grouped tableview color to a context, tinting it, and then using a bitmap of the context as a repeated background for your tableview somehow. I couldn't tell you just how to do that, though.
Why not just do the tinting in Photoshop or GIMP or something and save it as a 32x480 (or whatever res you need) image, and use that image as your tableview's background image. To get the initial pinstripe image, just make a fullscreen view with that as the background color.
A third option would be to place a translucent green view above another view with the grouped tableview background color. Don't know how well that would work, though.

Related

tint color is changing color of image in navigation bar swift 3

I put image instead of bar button item in navigation bar, and tint color is changing image color. I tried to put default tint color to be no color, but xcode is ignoring me. Also tried to make it transparent, but then whole image is transparent. Any ideas what should i do?
I believe you'll need to change the rendering mode of your UIImage that you use. UIImage has a method imageWithRenderingMode. You can feed that UIImageRenderingModeAlwaysOriginal to get an image that doesn't change based on tint color.
This is from memory and I'm not at a computer to try it out.

Making font colour negative to the background. iOS

I want to make text in a UILabel appear of a color negative to that background it is placed on.
I am placing the label on a web view, and I want that label to be always of a negative colour to the background so that no matter what colour (when web view is scrolled) is exactly below the text, it is always visible in a negative colour.
Thank you.
I don't recommend you to do that because the scrolling part of the webView won't be smooth with all those calculations in it. So I suggest you to set a background ImageView to your label and set a image with a negative color to your font color to that ImageView
An alternative would be setting the shadowColor to the opposite of the textColor (for example, white and black, respectively), ensuring that you'll always be able to pick out the text regardless of the web view's background color.
Don't forget to set the shadowOffset too!

Changing background colour within a TextField in Interface Builder

I want to be able to set the color inside a Text Field to be a different color than the default white.
I can make it grey by reducing the Alpha value but i want to use colors other than gray to denote certain conditions. i.e. red for a warning.
I hate asking such a simple question but I did some Google Searches and don't see anything to give me some insight.
I want to use colors, not an image as that would be more efficient than using images. But if it only works with images then guidance on that would be great.
I know there is a Background image you can set but that is more to make the border a different color. I want the color inside the text field area to be a different color.
If there is a way to do this in code but not in IB, that would be useful for me as well.
Thanks,
Dano
To change the background color in IB, set the Border to other than round rect.
Programmatically:
UITextField *myTextField;
myTextField.borderStyle = UITextBorderStyleNone;
myTextField.backgroundColor = [UIColor redColor];
You can change the background color within the Text Field attributes under the "view" tab in Interface Builder.
Note that the setting for "Background" setting for changing the background color is well hidden at the bottom of all the settings, unlike the "Background" setting for setting a background image, which is right at the top of the screen.
to set the background of the textField:
UITextField *myTextField;
myTextField.backgroundColor = [UIColor redColor];

What's this UI element?

What's the UI element that is top of that number buttons to display number ? (which is in light blue color)
It looks like a UINavigationBar with a prompt. However, the location of the gloss (which differs from your typical UINavigationBar) and the centering of the numbers (not shown) makes me think it is a custom view.
If you're trying to replicate it, I'd suggest starting with a UIView. Add a UIImageView with appropriate image for the the blue background and a UILabel for the text. Or, instead of the UIImageView, you could draw the background in the UIView's drawRect: method.

How to draw an tiled background image with alpha transparency on iPhone OS?

When I use UIColor -colorWithPatternImage: to create a view with an tiled background pattern, everything that is supposed to be transparent appears to be black. Of course I can't assign clearColor to the background, since the background is already this pattern image UIColor object.
I believe that this internally is using CGContextDrawTiledImage function. Or must I go directly with CGContextDrawTiledImage in this case?
You need to have something in the back that is not transparent. Otherwise the backmost background (black) will show through your transparent image.
Claus