Making font colour negative to the background. iOS - iphone

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!

Related

Custom UIButton image buttontype

If you can set a button's image even if it's button type is rounded rectangle, then what is the purpose of the button type to begin with? I usually use the custom button type, but does this in fact actually make a difference?
You can use UIButtonType to make a button of a standard type: a detail disclosure, an info, and so on. In these cases you would not need to set the image at all - the system will do it for you automatically.
When you pick rounded rectangle and set the image, the image would be clipped to the rounded rectangle's border; when you pick custom style, there will be no clipping.
Yes this definitely makes a difference. For example, if you have two buttons, One RoundRect and the other 2nd Custom.
Try to set a background color on both buttons. You will see the difference. The Custom Button has occupied the background color properly and the round rect has few issues.
Even with background Image, you can check both. The Custom button has no issues with setting images, as it has a transparent background and the round rect will have an issue on its corners.
UIButtonType definitely have difference of this.
I hope this is what you are looking for.

Double border to a UIButton

I have to display a UIButton like in the following image. Button size can be varying. How can I do that? Please suggest a way.
If you just want a simple outline (it's a little hard to tell from your image what the button is), create the button with UIButtonTypeCustom (so you get a blank slate) then set its background color to be black. next, get the CALayer of the button (through the layer method) and set the borderColor and borderWidth properties as desired.
make a view and set it's color a bit darker than your desired button color, then make a button a bit shorter than the view size and place it as your fit position, check n tell me if it helps youe

Tinting the background pinstripes of a grouped UITableView

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.

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];

Why does UIImageView appear to be partially transparent

I have a simple app that just displays a UIImageView. For some reason the image appears that it is partially transparent as it is much lighter than if I view the same image in photoshop. Any suggestions...I though by default a UIView is opaque.
You have probably changed the alpha of your imageView or the view itself. check for the the transparency of your imageview also. Because the default alpha of the imageview is 1 and opacity is also set to 100%. You might have chane one of these otherwise this is the problem of your image only
I don't believe that UIImageView is by default partially transparent? Try changing the background colour of the application and see if that affects the outcome of your image, if it is transparent it should be darker with a black background rather than white.