I'm facing a problem using a "open" font with Xcode. My aim is to get a text like the following:
I tried using this part of code:
// Creates the 'Welcome' label node
SKLabelNode *welcomeLabel;
welcomeLabel = [SKLabelNode labelNodeWithFontNamed:#"Welcome-font"];
welcomeLabel.position = CGPointMake(0, 0);
welcomeLabel.fontSize = 10.0;
welcomeLabel.fontColor = [UIColor redColor]; // TRY CHANGING COLOR
welcomeLabel.text = #"Welcome";
[self addChild:welcomeLabel];
but what I get is a red border and a transparent background:
This is my very first time using a font with alpha inside and I don't know how to figure it out! Could someone help me to achieve that?
(I am using Xcode 6.3 and the .ttf version of the font)
There is no concept of multi color fonts in iOS. The font itself does not describe the red area in your first image.
If you have the font in a solid variant, draw that first in red, then the black outline on top.
Related
Basic issue:
I believe the trick is with masking, but I am not able to get a good hold of how this is set.
Basically I have a bright image (set to a uiimageview object), and I have a label at very bottom (which is added on top of the image view) needs a well readable white text on it. Right now, the white text is hard to read (because of the bright background).
What I am doing:
I am setting a mask for the image view with something like
http://cl.ly/image/0i0N1p271d42
maskContainer = [CALayer layer];
UIImage *maskImg = [UIImage imageNamed:#"mask_profile"];
[maskContainer setContents:(id)[maskImg CGImage]];
CGRect frma = maskContainer.frame;
frma.size.width = self.frame.size.width;
frma.size.height = self.frame.size.height;
maskContainer.frame = frma;
[self.imageView.layer setMask:maskContainer];
Its messed up. The overall image starts fading on top.
Can anyone share their insight on the right way to mask?
You could set a drop shadow on your text to make is stand out even over a white background:
myLabel.layer.shadowOpacity = 0.8f;
myLabel.layer.shadowOffset = CGSizeMake(0, 0);
Easiest option is to adjust the alpha on the UILabel to the desired darkness in order to make the text stand out. If you do not want to hide the image and the image itself serves as a dark background, then set the alpha on the label to 0.
The best way to do this is to place the label in a uiview then create a gradient to apply as the background to the uiview. You can create the gradient as either an image with transparency or you can draw it in code. This will create a darkening effect on you bright image just behind the label so the text will pop.
If I have a UIButton and give it a red background, and the background size is a little too small or too big for my liking (but the tap target size is perfect), is there any way to change the size of them?
Basically the equivalent of adding padding in CSS so that it either takes up more area or less? Purely an aesthetic change.
Say with the background color applied to the button it visually takes up a 100px * 30px area. I want it to be 90px * 25px. Is this possible?
One way to do this, is to set the color of a sublayer of the button rather than the background color of the button itself.
- (void)viewDidLoad {
[super viewDidLoad];
CALayer *sub = [CALayer new];
sub.frame = CGRectInset(self.topButton.bounds, 5, 2.5); // this will make the layer 90x25 for a button that is 100x30
sub.backgroundColor = [UIColor redColor].CGColor;
[self.topButton.layer addSublayer:sub];
}
I'm using google map sdk in iOS 7.1
How can I set color for GMSPolyline, the default is black.
I have try with setStrokeColor and setSpans:
setStrokeColor:UIColorFromRGB(0xff0000, 1)
setSpans:#[[GMSStyleSpan spanWithColor:UIColorFromRGB(0xff0000, 1)]]
but it no have effect, I can only change the opacity by set alpha.
Anyone can help me ?
Thank you.
There are several ways to color polylines. Google's iOS SDK documentation has good info on this.
The simplest way is to set the polyline's strokeColor property:
polyline.strokeColor = [UIColor blueColor];
For more complex stuff, you'll want: GMSStyleSpan spanWithColor:(UIColor *)color
https://developers.google.com/maps/documentation/ios/reference/interface_g_m_s_style_span
They say to use spans, even to set the entire line's color:
polyline.spans = #[[GMSStyleSpan spanWithColor:[UIColor redColor]]];
Alternating white/black every 500 "segments" (changes with zoom, maybe meters?):
NSArray *styles = #[[GMSStrokeStyle solidColor:[UIColor whiteColor]],
[GMSStrokeStyle solidColor:[UIColor blackColor]]];
NSArray *lengths = #[#(500), #(500)];
[polyline setSpans:GMSStyleSpans(polyline.path, styles, lengths, kGMSLengthRhumb)];
... useful for making your own train polylines, for example.
Had the same problem with 1.7 version. Update to 1.8 (current).
Does anyone know the CSS color code? I want to use the same color for my web page. Thanks!
Scroll View Textured Background Color is kCGColorSpaceModelPattern i.e it is a pattern.
i had to use this color in my UIWebView page text color, so i converted this into color code like this
UIColor *color =[UIColor scrollViewTexturedBackgroundColor];
const CGFloat *components = CGColorGetComponents(color.CGColor);
NSString *colorAsString = [NSString stringWithFormat:#"%f,%f,%f,%f", components[0], components[1], components[2], components[3]];
which returned me value (1.000000,0.000000,0.000000,0.000000) which is a clear color.
I used alternate color that was some form of Gray color and resembled to scrollViewTexturedBackgroundColor.
Color code for that color is
rgb(77,77,77)
You can use it,it might help.
Native xCode colorPicker gives me next
rgb(111, 113, 121)
hex 6F7179
What color is the text of a default UIButton? I am trying o recreate it in some table view cells but not having luck. The closest I have come is:
[UIColor colorWithRed:0/255.0 green:51.0/255.0 blue:102.0/255.0 alpha:1];
Is that color, font size and style documented anywhere?
This is a pretty old question but I thought I would add my own answer anyway.
If you need a custom 'text only' button on iOS 7 and up that has the same color then do not create it with UIButton() but with UIButton.buttonWithType(UIButtonType.System).
That will give you a text button with the same properties as a standard system button, including the correct color. You can then use this button as a template and change things like the font size or add an image, etc.
Run a sample app with a UIButton on the simulator
Use spotlight to search for 'DigitalColor Meter'(with out the quotes, see below)
Use the pointer to point it at the text color, this will give you the RGB Value of the text
The font size and other values can be found using IB.
Try the following:
CGFloat red;
CGFloat green;
CGFloat blue;
CGFloat alpha;
UILabel *buttonLabel = [yourButton titleLabel];
UIColor *textColor = [buttonLabel textColor];
[textColor getRed:&red green:&green blue:&blue alpha:&alpha];
Now red, green, blue and alpha will contain the values you're looking for:
NSLog(#"Red: %f Green:%f Blue:%f Alpha:%f", red, green, blue, alpha);
For iOS 6 this will return:
Red:0.220000 Green:0.330000 Blue:0.530000 Alpha:1.000000
Text Color to Match Default UIButton Color [Blue]
It looks like someone pulled it out programmatically, but I have not confirmed it.
Personally what I would do is capture the color of the text in viewDidLoad using the property currentTitleColor and then use that when needed. That way you don't have to worry about rgb and the rest.
So in the interface set up a UIColor property and Outlet for your button
#property (strong,nonatomic)UIColor *backToTheDefaultTextColor;
#property (weak, nonatomic) IBOutlet UIButton *myButton;
In viewDidLoad get the buttons title color with
_backToTheDefaultTextColor = _myButton.currentTitleColor;
Then after you have changed the color of the title of the button and want to revert back simply put
_myButton.titleLabel.textColor = _backToTheDefaultColor;