How to make inverted shadow on UILabel? - iphone

I'm trying to get an "embed" effect on my UILabel in my app.
Here's what I mean:
I want it to look like the font is "embedded" or pressed into the background. Please note this font is dynamic, the UILabel will be changed programmatically.
Any ideas as to how this can be done, or as to what font looks like this?
Thanks in advance!
--------------------------------------------------------------------------------------------------------------
Edit: Thanks to fbrunel, I figured out how to do it. Check out the result, though.
It really doesn't look very nice, any ideas why?

It's done using an "inverted" shadow on the text. On UILabel you have two properties to do this: shadowColor and shadowOffset (the direction of the shadow).
label.shadowColor = [UIColor whiteColor];
label.shadowOffset = CGSizeMake(0, 1);
Will do the trick.

Related

How to use colorWithPatternImage: with UILabel

I am trying to create a UILabel with customized text that shows the current score of a game. The customer has given me screen shots where they would like the color/pattern of the text to be like that of a wooden panel, so it looks to be brownish with darker swirls within it.
Is this even possible? I have spent an enormous amount of time scouring the web for something related to this and have found nothing concrete. One lead I followed that didn't pan out was using:
[UILabel setTextColor:[UIColor colorWithPatternImage:[UIImage imageNamed: #"WoodenPanel.png"]]];
It seems like there's a way to use an image and set it as the color for the text. But what results when I use this is a completely black UILabel. Is this on the right track? Or is this simply not possible?
You have to do it like this:
[labelName setTextColor:[UIColor colorWithPatternImage:[UIImage imageNamed:#"IMAGENAME.PNG"]]];
NOT like you did:
[UILabel setTextColor:[UIColor colorWithPatternImage:[UIImage imageNamed:#"IMAGENAME.PNG"]]];
You have to put the name of the declared label instead of UILabel
Can text in UILabel have a colorWithPatternImage: assigned to it?
It does use the colorWithPatternImage though
What do you mean by it didn't pan out.
Also this is a possible duplicate of the link I just gave you.
It turns out I had actually implemented it correctly. The line of code I provided above was not an exact line out of my program, but more of a generality.
The reason I was getting a completely black font was that part of the particular image I was using was entirely black. It seems that the image isn't scaled down to fit the text and UILabel so what was being revealed was the bottom 1/5 of the image. I did not have to solve this problem as the image provided for me to implement this was a repetitive pattern throughout the image so that any part of the image would produce the desired effect of a wooden panel type color font.

Outline for UILabel text

How do I add a black outline to my white UILabel text?
One option is to set the shadow, which might not be exactly what you want, but achieves a similar effect. You can manually adjust the offset:
UILabel *myLabel = ...;
lbl.shadowColor = [UIColor whiteColor];
lbl.shadowOffset = CGSizeMake(0, -1.0);
Please note that you can also define this in Interface Builder for your UILabel.
shadow http://i.minus.com/jbiG0jVdOxJbgh.png
If this is not enough for you check out this blog post which deals with subclassing UILabel to get a glow effect:
(source: redrobotstudios.com)
Disclosure: I'm the developer of THLabel.
I've released a UILabel subclass a while ago, which allows an outline in text and other effects. You can find it here: https://github.com/tobihagemann/THLabel
I'm using Core Text and Core Graphics to achieve the effect.
For iOS5, the usual way is to use CoreGraphics to set fill/stroke and then render the graphics. It can be pretty tricky to get the alignment correct for all font sizes though.
I recommend looking at my solution here. You can either use it straight (it has diffuse shadows as well), or simply pick out the code that does the outline. For iOS6 there is a neater (smaller) solution which works even better. Look here.
I am sure this code will solve your problem.
In KSLabel.m class see this line of code
// Outline color
self.textColor = [UIColor whiteColor];
change it to
self.textColor = [UIColor blackColor];
and you will see the black border of the text.

How to type a text in imgeview. Right now sucessfully drawing using mouse

How to type a text in imgeview... right now successfully drawing using mouse. I need to type text in same image view using keyboard...
Try superimposing a UITextView on top of your UIImageView and set appropriate frames for both so that the text appears until where you want it to appear.
Set this property for your UITextView
myTextView.backgroundColor = [UIColor clearColor];
myTextView.textColor = [UIColor redColor]; //or whatever color you like based on the background image in your UIImageView.
Of course you will have to take care of the scrolling when the keyboard comes up after the UITextView becomes active.
If you want more assistance, please elaborate upon your question and your need.

How to change the textsize in a segment in UISegmentController in a XIB file

I am developing an iPad application where i want to reduce the textsize in a segment in a UISegmentController.Please help. I also want to change the selected segment color. currently the default color we get when a segment is selected is blue. I want to change it to red. Please help me if anyone is aware of these solutions. I am trying to use a Xib file to make the segments.
Yes...You can change the color...By adding the below code to the style your preferred the default tintcolor of segment can be changed...
segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar;
segmentedControl.tintColor = [UIColor greenColor];

iPhone UISegmentedControl button states on black UIToolbar

I have a UISegmentedControl on a black UIToolbar. I have set the style to Bar and set the background color to clear (also tried black). I have tried setting the tintColor clear (also tried black). My buttons turn black to match the black UIToolbar. However, the buttons no longer indicate a clicked state like they do when the UISegmentedControl is the default blue/grey. What do I have to do to make the buttons indicate a black/grey clicked state? Please let me know. Code used so far to set the color of the UISegmentedControl:
viewTypeSelection.segmentedControlStyle = UISegmentedControlStyleBar;
viewTypeSelection.backgroundColor = [UIColor clearColor];
While not a perfect solution, this works pretty well
// set the color
viewTypeSelection.segmentedControlStyle = UISegmentedControlStyleBar;
viewTypeSelection.tintColor = [UIColor darkGrayColor];
The buttons have state change and it looks OK. Here is a post that has a few more details and might help someone looking for a similar solution:
UISegmentedControl black?
You may have set the color of the bar with tintColor instead of setting barStyle like so:
self.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;