Hi friends i have one requirement that word wrapping on label. Using myLabel.lineBreakMode=NSLineBreakByCharWrapping;
I am able to show the text in label like below
Designation : I am working as iOS
Developer
But i want to show
Designation : I am working as iOS
Developer
Is this possible to achieve above requirement within one label?
Thanks
I tried it and got it solved. I have attached the screenshot. You just need to do the following:
set lines property of label to 2.
set height and width of the label through xib and its done.
In Xcode, you can design your UILabel to have 2 lines. Then, you just need to add a new line ("\n") after the word "iOS", and center-align everything? If your caption is always the same you can pre-enter it in Xcode. To add a new line, just press alt+Enter.
Would that be acceptable?
No, it's not possible with UILabel, Unless workaround to this. I think, you know how to done manually. But You can't wrap the content like above. Simple answer is you can use two label.
Not possible. UILabel just renders text according to properties that you defined. If you want to do it ideally then use two UILabels. & Place them according to your need.
Related
I say 'hyperlink' because I don't know what else to call it, and that is how i'd like it to appear.
Obviously this is possible using a combination of labels and buttons, but my labels and buttons are programmatically generated and I imagine i'd have to also programmatically arrange them, which would likely be tedious and inflexible in terms of changing font sizes etc.
Any ideas/approaches would be much appreciated!
As an example, look at Instagram's following and news feed:
You should set userInteractionEnabled and then add a UITapGestureRecognizer to the label.
Have a look at Nimbus Attributed Label it can provide the functionality you are looking for.
I'm trying to display more than one line of text in a custom UIMenuItem.
I've tried using a simple "\n" in the title property of the UIMenuItem but with no luck.
Example:
UIMenuItem *menuItem; //Is then allocated properly....
// Before the Menu is displayed
menuItem.title = #"This is a first line.\nThis is a second line.";
Unfortunately I just end up with one line being displayed...
What I want to achieve is something similar to what you can see upon a LongPress on a row in the Apple iPod/Music app.
I've just found out about this github project as a solution:
https://github.com/questbeat/QBPopupMenu
You can display whatever custom UIView within a MenuItem. So I inserted a multi-line UILabel and that works.
However I would rather use the native Apple UIMenutItem approach if this is possible. Any ideas? Thanks in advance.
You would need to change some internal property of the UIMenuItem, but unfortunately Apple does not provide a way to do it.
So, as for today, there's not way to change the display of a UIMenuItem.
Have you tried '\r' instead of '\n'?
i am in need to use a text field in my application but the ones provided by XCode are only 1 line long and you can only change the width but not the hight.
I was wondering if its possible to make it look more lines long?
Is it only possible with customization and if yes any good tutorials?
Thank you!
First off, you can actually change the height of a UITextField. Just change the border style in the Attributes Inspector to anything except the default "rounded corners". You can then resize it right in Interface Builder. If you really wanted to, you could even change it back in your viewDidLoad method like this:
self.myTextField.borderStyle = UITextBorderStyleRoundedRect;
However, to have multiple lines, you have to use a UITextView. It's by default multi-line, but see the Apple documentation for more information.
You can use a UITextView. The document about it here. If you need something else, please post an image of what you want to achieve.
I need to show a registered trademark symbol in a superscript (exponent position) in respect to the name of the label. need to show it in a uipickerView and a label. I havent found the option of how to show the unicode \u00AE in the exponent position,
1) Should I use 2 labels in different positions in the uipickerView?
2) Or, Show an image in the picker view with the intended name?
Thanks a lot!
For me this works:
#"Sometext \u00AE other text".
Can you check?
The unicode symbol is very slightly superscripted but I guess this isn't enough for you. You can't mix font sizes and styles within a label so there isn't an easy answer. Two labels probably won't work because you will be having to adjust the position of the R sign.
The simplest answer is probably to subclass UILabel and, in the drawRect method, call the super implementation and then manually draw the R string where you want it. You can get the size of the existing text using the NSString drawing methods so you'll know where to put the symbol.
I ended up using an image in the picker view to show the superscript as needed,
inspired by the catalog app from apple,
if you are a noob like me and would like to check the project, please go to
project in Github
I have a XIB file of type View XIB. In it I have a View controller, and in the View controller I have a label.
I have long text that I want to break, but it doesn't - it gets truncated.
I tried this solution - I did it in the attribute window - but it doesn't help.
You could use a TextView and disable the Editable and User Interaction Enabled options in IB.
use this
myLabel.lineBreakMode = UILineBreakModeWordWrap;
if you are worried about backwards compatibility use this because the comand i mentioned before was introduced in iOS 6.0
myLabel.numberOfLines = 0;
I have been running into a similar problem. I started out with a label, but wanted multi-lines and a UITextView worked great for this, at first. Because I am using a third party library (MBProgressHUD) to handle stuff like progress messages and what not, I had thread problems when trying to update a UITextView and show the progress message at the same time.
So I went back to UILabel which actually didn't have thread problems. I found a property to allow a specific number of lines of my choosing, and had to create the label big enough to display those lines. The downfall to this approach is that I don't get the context menus like Copy, Paste, etc. but more importantly I'm not running into thread problems. I can always embed this into a UIScrollView in the future if I so choose.
You could check out my category for UILabel on GitHub. https://gist.github.com/1005520
This lets you resize the height of the label to accommodate the content.
From the Attiribute inspector, choose LineBreaks->Word Wrap option when you have selected the lablel. Also increase the number of lines Label->Lines.
Try Following steps to solve issue :
Drag out a UITextView.
Double-click it to edit text, place cursor where you want the
paragraph break.
Option-Enter a couple of times to create a blank line & paragraph.