how to add button in label text - ios

I don't know if this is applicable in iphone. I'm trying to add button inside label text. See image below.
If you see there is href or anchor(web name) inside the square that I'm pointing. Can I put button inside the text? These data came from rest api. I need an advice if this applicable or possible to do that. If ever this is applicable please give me idea on how to do that.
Thanks in advance

I think what you want is actually add user interaction to certain range of the string, right?
This can be easily achieved by this library TTTAttributedLabel
Please take a look at it and then you can dynamically set what you want to link.

Related

Format UILabel with image and links

How can I add a string with link and image in a UIlabel using swift code.
Below is a sample what I needed:
Visit to the following link Terms and conditions 💼 for specific
instructions.
I need the Terms and conditions and the bag in red collar and remaining text in grey color. Tapping on red coloured text opens a link.
Anyone please help.
The short answer is, don't do that. A UILabel displays a string. That's what it's made to do. Adding images and links to a label is stretching it well beyond its intended purpose.
You can take a generic UIView and add subviews for your text and your image(s). Build your desired contents out of the elements you need.
I would suggest using a UITextView since that supports clickable links. Set it's editable flag to false and turn on link detection.
As per your problem described here. I have found a perfect solution, as per your requirement.
Here is the link to your solution : Link
You can try this and bridge it as it's written in Objective-C
KILabel
I solved it by adding an attributed text and user interaction to handle link tap. To add image NStextAttachment can be used. Write method to handle tap gesture for label using range.

How to get Text of a Button in limejs

I have tried to use
var b = button1.getText() to get the text of a button in limejs but it does not seem to work. Can anyone help?
A Glossy Button does not have a getText method as is, but you could alter the library and create it if that's what you need. I'm not sure why you would want to get the text of a button however, it seems trivial to me as it's mostly hard coded. What you could also do is set a listener to the button which then in turn sets a variable to the text you initially placed in the button.
Please take a look at the documentation of LimeJS before asking questions like this, you could easily have spotted the problem :)

How to add UI Objects (Image) to a UITextView or UITextField?

I would like to achieve something like the following for a UITextField or a UITextView.
The Object added to will be treated like a string when we delete texts.
I know I can add a backgrand image and get it done with too many codes.
Please let me know the best possible way to achieve this and kindly give me some pointers.
I would recommend you use Text Kit. Using a UITextView with Text Kit allows you to define exclusion paths (which could be used to form text around subviews) or to add attachments into the text directly.
Here's another answer that gives some pretty good direction: How to wrap text around attachments using iOS7 Text Kit?

Is it possible to 'hyperlink' text within a UILabel/TextView but activate a segue on tap of this 'hyperlink'?

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.

Is it possible to customize a text field , in iOS?

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.

Resources