Question

http://i.imgur.com/lF60tKu.png

I have the sources of these letters and I am trying to create the gray effect around in objective-c. But I can not, does anyone have an idea how to do this?

Was it helpful?

Solution

Take a look at GSBorderLabel.

It's good because it adds outer border and not inner border on characters and it's very easy to customise it.

For example:

GSBorderLabel *myLabel = [[GSBorderLabel alloc] initWithFrame:CGRectMake(0, 50, 300, 100)];
myLabel.textColor = [UIColor yellowColor];
myLabel.textAlignment = NSTextAlignmentCenter;
myLabel.borderColor = [UIColor grayColor];
myLabel.borderWidth = 20;
myLabel.text = @"Review";
myLabel.font = [UIFont fontWithName:@"Party LET" size:60.0];

image

OTHER TIPS

If you're targeting iOS 6 and up, there isn't much over head for this. You can simply use NSAttributedString to add a stroke to an existing font. Mind you, this will not add the stroke to the font, just render it on screen.

NSDictionary *attributes = @{NSStrokeColorAttributeName: [UIColor grayColor], NSStrokeWidthAttributeName : @3};

NSString *inputText = @"Some text";
NSAttributedString *attributedString = [[NSAttributedString alloc] initWithString:inputText attributes:attributes];

[self.someLabel setAttributedText:attributedString];

You can try this:

    #import <QuartzCore/QuartzCore.h>

....

    titleLabel.layer.shadowColor = [[UIColor grayColor] CGColor];
    titleLabel.layer.shadowRadius = 3;
    titleLabel.layer.shadowOpacity = 1;
    titleLabel.layer.shadowOffset = CGSizeMake(0, 0);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top