I want to create a clickable label on my app leading me to a Safari webpage. I also want the user to be able to phone the numbers only by clicking on them ?
Thanks for your advices
I want to create a clickable label on my app leading me to a Safari webpage. I also want the user to be able to phone the numbers only by clicking on them ?
Thanks for your advices
Use
UITextView
instead ofUILabel
and it has a property to convert your text to hyperlink.Objective-C:
Swift:
This will detect links automatically.
See the documentation for details.
Swift 4.0 possible solution using UIButton
If you want this to be handled by UILabel and not UITextView, you can make UILabel subclass, like this one:
This class was made by reusing code from this answer. In order to make attributed strings check out this answer. And here you can find how to make phone urls.
You can make custom UIButton and setText what ever u want and add method with that.
You can use a
UITextView
and select Detection for Links, Phone Numbers and other things in the inspector.