I´m using a form with 11 individual labels, which each one is responsible to a specific letter/symbol. It´s necessary to create a effect similar to decoding/decrypting a sentence.
The form inits as: XcT25vCh##*&
and after some character-change effects it ends with: Normal Text
Everything is functioning perfectly, but when I reduce the space among the characters (to put them really in a narrow space), the subsequent character (label) overrides the previous one, make it hidden.
In other words, if I keep them in a fixed space (even being a justified font as Arial), everything is OK. But if I try to reduce the horizontal space among them, the right label overrides the previous one.
All labels are marked as TRANSPARENT BACKGROUND and it has no positive effect.
I tried also to set Autosize ON and OFF, again, without any positive effect.
How can I simulate a decrypting string without have to keep all characters with a fixed (and large) horizontal space among them?
Note that the problem is not related to the label itself (the character width), but to the fact of each one is capping the previous one.
Thank you.
Related
I am having trouble making text fields look acceptable when using different typefaces.
See this screenshot taken from a test app I made to demonstrate the problem. It consists of a single XIB, with no code in the delegate or anywhere else. This is on OSX Mavericks with Xcode 5.1.1 but I haven't tried on other versions.
The default system font looks fine in the top text field, as you'd expect. Compare this to the one below: same exact size and shape, all I did differently was change the typeface in Interface Builder. Text is pushed downwards, and descending letters (lowercase pqjg) are clipped. The Menlo example below is also pushed downwards, though not quite as badly.
How do I fix this?
A quick test shows Lucida Grande and Helvetica require 17 pixels, and Menlo requires 19 pixels:
Note that this excludes the border and shadows, so you need your text view to be significantly larger than that to guarantee it will fit.
Interface Builder has been specifically designed for Lucida Grande, it knows it can get away with being too small because that font doesn't use all the space it has available. Doesn't work well with other fonts.
You can resolve this a couple of different ways:
• Enable "Uses Single Line Mode" on the Text Field Panel. When I first
encountered this issue it wasn't obvious that this would automatically
align the text vertically within an NSTextField.
or...
• Simply adjust the size of the NSTextField using the adjustment boxes
that appear after you click on it. You can also adjust them through
the "Control" properties.
In rc2, the styling of the tabs of tabpanels has changed. One big downside of this is that before the size of the tab itself was determined by the size of the title. Now they are locked to a fixed size, and so the title can be truncated if it is too long.
Is there a way to override this behavior? I've tried to set maxTabWidth to 'undefined', but that does not seem to help.
Here is an example of the new tabs:
And what they looked like previously:
Note that you can sort of get around this by setting minTabWidth to a high enough number, but then your tabs can take up a lot more space that they otherwise would, so this is not really practical for a window with a fair number of tabs.
I've read here in many questions how to limit the length of my uitextfield programmatically by implementing shouldChangeCharactersInRange method but isn't there a way to do it in storyboard? it seems, to me,like a bad performance practice to check it with every keyboard click
In every other programing language i know that has an IDE + ui editor the control has a property to set max length same as it has for setting the text, font, border style etc.
There's no way of setting that from the storyboard, as is a method that is called by the delegate, so you need to do it programatically.
You can't set a maximum character limit by setting something in the storyboard. You need to do it programmatically. And as long as you're just doing character limit checking, there's no noticeable performance impact to this. In fact if you think about it, regardless of whether you implement the check or it was somehow a storyboard option, it would still have to execute some code each time to see if it could add another character. Also this is so insignificant compared to the work involved in redrawing the screen that you would not notice any difference at all.
It's important to note in implementing a character limit check that you also have to handle when the user pastes text in, because this adds many characters at once. So you have to decide on how to handle that, whether you take just the characters up until your limit, or if you don't accept any of them because it exceeds your limit.
You also have to handle the case that the user is adding characters from the beginning or somewhere in the middle. Do you start deleting characters off the end to stay within your limit or not accept new characters anywhere in the string? These are decisions you have to make and account for in your code.
However, as I said before, all of this is so minor a burden on the processor that you won't notice any difference.
I have several UITextViews that contain numbers between one and three digits. I'd like these views to expand and shrink as the number becomes larger or smaller. At the moment the text is shrinking and the TextViews size remains the same.
I'd preferable like to do this using the xib file (I'm very surprised this isn't a meagre check box) but a coded answer would be great if this isn't possible.
I'd recommend using the contentSize property of the UITextView:
self.textView.frame = CGRectMake(self.textView.frame.origin.x, self.textView.frame.origin.y, self.textView.contentSize.width, self.textView.contentSize.height);
In VB.NET, I want to find out how many whole lines of text I could fit inside a multiline textbox. What is the best way to do this?
Considering that the WPF TextBox controls don't have a Multiline property, this is presumably for a WinForms application.
To determine how much text you can fit in a given size (the dimensions of the TextBox control) I would suggest using the TextRenderer.MeasureText method to determine the height of a single character. Divide the height of the TextBox control by the height of the character to get the number of lines visible at one time.
Keep in mind that the measurements of characters may potentially differ in so much that the measurement of an asterisk (*) may be very small, whereas the measurement of an octothorpe (#) may be much larger. The MSDN page seems to state however, that this is a non-issue as long as you use MeasureText(String, Font) and not any of the other overloads.