1668053903
Atributika
is an easy and painless way to build NSAttributedString. It is able to detect HTML-like tags, links, phone numbers, hashtags, any regex or even standard ios data detectors and style them with various attributes like font, color, etc. Atributika
comes with drop-in label replacement AttributedLabel
which is able to make any detection clickable
NSAttributedString is really powerful but still a low level API which requires a lot of work to setup things. It is especially painful if string is template and real content is known only in runtime. If you are dealing with localizations, it is also not easy to build NSAttributedString.
Oh wait, but you can use Atributika!
let b = Style("b").font(.boldSystemFont(ofSize: 20)).foregroundColor(.red)
label.attributedText = "Hello <b>World</b>!!!".style(tags: b).attributedString
Yeah, that's much better. Atributika is easy, declarative, flexible and covers all the raw edges for you.
AttributedLabel
is a drop-in label replacement which makes detections clickable and style them dynamically for normal/highlighted/disabled
states.+
operator to concatenate NSAttributedString with other attributed or regular stringslet redColor = UIColor(red:(0xD0 / 255.0), green: (0x02 / 255.0), blue:(0x1B / 255.0), alpha:1.0)
let a = Style("a").foregroundColor(redColor)
let font = UIFont(name: "AvenirNext-Regular", size: 24)!
let grayColor = UIColor(white: 0x66 / 255.0, alpha: 1)
let all = Style.font(font).foregroundColor(grayColor)
let str = "<a><a></a>tributik<a></a></a>"
.style(tags: a)
.styleAll(all)
.attributedString
let str = "#Hello @World!!!"
.styleHashtags(Style.font(.boldSystemFont(ofSize: 45)))
.styleMentions(Style.foregroundColor(.red))
.attributedString
let str = "Check this website http://google.com"
.styleLinks(Style.foregroundColor(.blue))
.attributedString
let str = "Call me (888)555-5512"
.stylePhoneNumbers(Style.foregroundColor(.red))
.attributedString
let links = Style.foregroundColor(.blue)
let phoneNumbers = Style.backgroundColor(.yellow)
let mentions = Style.font(.italicSystemFont(ofSize: 12)).foregroundColor(.black)
let b = Style("b").font(.boldSystemFont(ofSize: 12))
let u = Style("u").underlineStyle(.styleSingle)
let all = Style.font(.systemFont(ofSize: 12)).foregroundColor(.gray)
let str = "@all I found <u>really</u> nice framework to manage attributed strings. It is called <b>Atributika</b>. Call me if you want to know more (123)456-7890 #swift #nsattributedstring https://github.com/psharanda/Atributika"
.style(tags: u, b)
.styleMentions(mentions)
.styleHashtags(links)
.styleLinks(links)
.stylePhoneNumbers(phoneNumbers)
.styleAll(all)
.attributedString
Atributika
APIs styleXXX
produce AttributedText
which can be converted into NSAttributedString
. Basically AttributedText
just contains string, base style and all the detections.
AttributedLabel
is able to display AttributedText
and makes detections clickable if style contains any attributes for .highlighted
let tweetLabel = AttributedLabel()
tweetLabel.numberOfLines = 0
let all = Style.font(.systemFont(ofSize: 20))
let link = Style("a")
.foregroundColor(.blue, .normal)
.foregroundColor(.brown, .highlighted) // <-- detections with this style will be clickable now
tweetLabel.attributedText = "@e2F If only Bradley's arm was longer. Best photo ever.😊 #oscars https://pic.twitter.com/C9U5NOtGap<br>Check this <a href=\"https://github.com/psharanda/Atributika\">link</a>"
.style(tags: link)
.styleHashtags(link)
.styleMentions(link)
.styleLinks(link)
.styleAll(all)
tweetLabel.onClick = { label, detection in
switch detection.type {
case .hashtag(let tag):
if let url = URL(string: "https://twitter.com/hashtag/\(tag)") {
UIApplication.shared.openURL(url)
}
case .mention(let name):
if let url = URL(string: "https://twitter.com/\(name)") {
UIApplication.shared.openURL(url)
}
case .link(let url):
UIApplication.shared.openURL(url)
case .tag(let tag):
if tag.name == "a", let href = tag.attributes["href"], let url = URL(string: href) {
UIApplication.shared.openURL(url)
}
default:
break
}
}
view.addSubview(tweetLabel)
Current version is compatible with:
swift-3.2
branch)Note: AttributedLabel
works only on iOS
Because in Belarusian/Russian we have one letter 't' (атрыбутыка/атрибутика). So basically it is transcription, not real word.
Add github "psharanda/Atributika"
to your Cartfile
Atributika is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "Atributika"
git submodule add https://github.com/psharanda/Atributika.git
Atributika
folder & drag Atributika.xcodeproj
into your project treeAtributika.framework
to your target's Link Binary with Libraries
Build Phaseimport Atributika
and you're ready to goAuthor: psharanda
Source Code: https://github.com/psharanda/Atributika
License: MIT license
#swift #html #ios #hashtag #tags
1596090180
HTML tags are keywords used in HTML to display web-pages with certain properties. They are further used for defining HTML elements. An HTML element consists of a starting tag, some content, and an ending tag. The web browser reads the HTML document from top to bottom, left to right. Each HTML tag defines a new property that helps in rendering the website.
The ‘<>’ brackets contain an HTML tag. There are two types of HTML tags- empty tags or singleton tags and container tags. Singleton tags or empty tags do not contain any content such as an image or a paragraph and hence do not need to be closed, whereas container tags should be closed.
Syntax
Examples of:
Empty tag:
,
Container tags:
Paragraph
Paragraph
Output-
Head tags:
#html tutorials #html image tags #html link tags #html list tags #html tags #html
1650364405
Pick the right hash tags and enjoy likes and comments on the post.
Making engaging reels about the travels, fashion, fitness, contest, and more, the results are not satisfactory. All you get is a few likes, comments and nothing else. You need the engagement on your post to bring more business to you. How can you bring interaction to the content? Indeed you can buy real instagram likes uk to get high rates. But how can you make the Instagram world hit the likes button under the post? You need to boost the reach. You must present your content to the right audiences to get higher interaction rates.
Your Instagram #tags are the power tool that works like magic for influencers and businesses. The blue text with # is the magical option that increases the viability of the posts. The Instagram algorithm keeps on changing, and now the engagement on the post is a must to place the content at a higher place in followers’ feed. For this, you require more likes and comments under the post. For this, you must lift the reach by using perfect tags.
Why are hashtags popular on Instagram?
Let me clear it for you. Do you know how many active users this digital handle has? It is about 2B and more, and the count is changing every day. Each of the followers must be posting something on the handles. Thousands of profit must be of a similar niche as yours. If you are the business and running the clothing brands, then many other companies deal with clothes. So, customers or followers have many choices to choose from. Why would they follow you or purchase from your companies?
Your reply must be that you offer quality material at the best rates. But how does anyone finds out about you? Indeed you can buy active instagram followers uk to bring more fans, but how can you boost the reach of your voices. All businesses must represent their product to the right audiences, but how?
Of course, hashtags.
Table of Contents
There are some basic tags that you can use, but if you are more specific about your approach, choose the relevant tags for your business. Your #tags game must be industry oriented. So in this part, you will learn about the famous tags as per various niches.
Tags for Travel Niche
Indeed this niche is famous on Instagram, and influencers earn handsome amounts. These #tags are best for you if you possess a similar place. Use them smartly and rightly!
#TravelPhotography
#PicOfTheDay
#NaturePhotography
#TravelBlogger
#beautiful
#landscape
#adventure
#explore
#instatravel
#photo
#trip
#summer
#travelgram
#photography
#art
#travel
#wanderlust
#nature
#instagood
#PhotoOfTheDay
After thee travel next most famous niche is fashion. You can earn handsome amount form it. But for this you need to pick the right tags form the following:
So, what to boost your fitness business then uses these tags and enjoys likes:
Best Tags for Giveaway
So, are you arranging the giveaway and want a maximum number of people to participate? If so, then it is time to boost the reach vis using these tags
Are you the reels queen, or do you want to become the one? Then these below mentioned tags are for you. But don’t go for all of them because you can use only thirty of them. Pick it smartly!
Do you love to eat and what to share your experience with another foodie on Instagram? If you are visiting any cafe, then before uploading, always add one of the following tags!
There is a long list of each niche, and you can use all of them. If you are confused about what to pick and whatnot, here is the guide to choosing the perfect tag.
Study your competition. Review their post and study the tags they are using.
1668053903
Atributika
is an easy and painless way to build NSAttributedString. It is able to detect HTML-like tags, links, phone numbers, hashtags, any regex or even standard ios data detectors and style them with various attributes like font, color, etc. Atributika
comes with drop-in label replacement AttributedLabel
which is able to make any detection clickable
NSAttributedString is really powerful but still a low level API which requires a lot of work to setup things. It is especially painful if string is template and real content is known only in runtime. If you are dealing with localizations, it is also not easy to build NSAttributedString.
Oh wait, but you can use Atributika!
let b = Style("b").font(.boldSystemFont(ofSize: 20)).foregroundColor(.red)
label.attributedText = "Hello <b>World</b>!!!".style(tags: b).attributedString
Yeah, that's much better. Atributika is easy, declarative, flexible and covers all the raw edges for you.
AttributedLabel
is a drop-in label replacement which makes detections clickable and style them dynamically for normal/highlighted/disabled
states.+
operator to concatenate NSAttributedString with other attributed or regular stringslet redColor = UIColor(red:(0xD0 / 255.0), green: (0x02 / 255.0), blue:(0x1B / 255.0), alpha:1.0)
let a = Style("a").foregroundColor(redColor)
let font = UIFont(name: "AvenirNext-Regular", size: 24)!
let grayColor = UIColor(white: 0x66 / 255.0, alpha: 1)
let all = Style.font(font).foregroundColor(grayColor)
let str = "<a><a></a>tributik<a></a></a>"
.style(tags: a)
.styleAll(all)
.attributedString
let str = "#Hello @World!!!"
.styleHashtags(Style.font(.boldSystemFont(ofSize: 45)))
.styleMentions(Style.foregroundColor(.red))
.attributedString
let str = "Check this website http://google.com"
.styleLinks(Style.foregroundColor(.blue))
.attributedString
let str = "Call me (888)555-5512"
.stylePhoneNumbers(Style.foregroundColor(.red))
.attributedString
let links = Style.foregroundColor(.blue)
let phoneNumbers = Style.backgroundColor(.yellow)
let mentions = Style.font(.italicSystemFont(ofSize: 12)).foregroundColor(.black)
let b = Style("b").font(.boldSystemFont(ofSize: 12))
let u = Style("u").underlineStyle(.styleSingle)
let all = Style.font(.systemFont(ofSize: 12)).foregroundColor(.gray)
let str = "@all I found <u>really</u> nice framework to manage attributed strings. It is called <b>Atributika</b>. Call me if you want to know more (123)456-7890 #swift #nsattributedstring https://github.com/psharanda/Atributika"
.style(tags: u, b)
.styleMentions(mentions)
.styleHashtags(links)
.styleLinks(links)
.stylePhoneNumbers(phoneNumbers)
.styleAll(all)
.attributedString
Atributika
APIs styleXXX
produce AttributedText
which can be converted into NSAttributedString
. Basically AttributedText
just contains string, base style and all the detections.
AttributedLabel
is able to display AttributedText
and makes detections clickable if style contains any attributes for .highlighted
let tweetLabel = AttributedLabel()
tweetLabel.numberOfLines = 0
let all = Style.font(.systemFont(ofSize: 20))
let link = Style("a")
.foregroundColor(.blue, .normal)
.foregroundColor(.brown, .highlighted) // <-- detections with this style will be clickable now
tweetLabel.attributedText = "@e2F If only Bradley's arm was longer. Best photo ever.😊 #oscars https://pic.twitter.com/C9U5NOtGap<br>Check this <a href=\"https://github.com/psharanda/Atributika\">link</a>"
.style(tags: link)
.styleHashtags(link)
.styleMentions(link)
.styleLinks(link)
.styleAll(all)
tweetLabel.onClick = { label, detection in
switch detection.type {
case .hashtag(let tag):
if let url = URL(string: "https://twitter.com/hashtag/\(tag)") {
UIApplication.shared.openURL(url)
}
case .mention(let name):
if let url = URL(string: "https://twitter.com/\(name)") {
UIApplication.shared.openURL(url)
}
case .link(let url):
UIApplication.shared.openURL(url)
case .tag(let tag):
if tag.name == "a", let href = tag.attributes["href"], let url = URL(string: href) {
UIApplication.shared.openURL(url)
}
default:
break
}
}
view.addSubview(tweetLabel)
Current version is compatible with:
swift-3.2
branch)Note: AttributedLabel
works only on iOS
Because in Belarusian/Russian we have one letter 't' (атрыбутыка/атрибутика). So basically it is transcription, not real word.
Add github "psharanda/Atributika"
to your Cartfile
Atributika is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "Atributika"
git submodule add https://github.com/psharanda/Atributika.git
Atributika
folder & drag Atributika.xcodeproj
into your project treeAtributika.framework
to your target's Link Binary with Libraries
Build Phaseimport Atributika
and you're ready to goAuthor: psharanda
Source Code: https://github.com/psharanda/Atributika
License: MIT license
1650870267
In the previous chapters you've learnt how to select individual elements on a web page. But there are many occasions where you need to access a child, parent or ancestor element. See the JavaScript DOM nodes chapter to understand the logical relationships between the nodes in a DOM tree.
DOM node provides several properties and methods that allow you to navigate or traverse through the tree structure of the DOM and make changes very easily. In the following section we will learn how to navigate up, down, and sideways in the DOM tree using JavaScript.
You can use the firstChild
and lastChild
properties of the DOM node to access the first and last direct child node of a node, respectively. If the node doesn't have any child element, it returns null
.
<div id="main">
<h1 id="title">My Heading</h1>
<p id="hint"><span>This is some text.</span></p>
</div>
<script>
var main = document.getElementById("main");
console.log(main.firstChild.nodeName); // Prints: #text
var hint = document.getElementById("hint");
console.log(hint.firstChild.nodeName); // Prints: SPAN
</script>
Note: The
nodeName
is a read-only property that returns the name of the current node as a string. For example, it returns the tag name for element node,#text
for text node,#comment
for comment node,#document
for document node, and so on.
If you notice the above example, the nodeName
of the first-child node of the main DIV element returns #text instead of H1. Because, whitespace such as spaces, tabs, newlines, etc. are valid characters and they form #text nodes and become a part of the DOM tree. Therefore, since the <div>
tag contains a newline before the <h1>
tag, so it will create a #text node.
To avoid the issue with firstChild
and lastChild
returning #text or #comment nodes, you could alternatively use the firstElementChild
and lastElementChild
properties to return only the first and last element node, respectively. But, it will not work in IE 9 and earlier.
<div id="main">
<h1 id="title">My Heading</h1>
<p id="hint"><span>This is some text.</span></p>
</div>
<script>
var main = document.getElementById("main");
alert(main.firstElementChild.nodeName); // Outputs: H1
main.firstElementChild.style.color = "red";
var hint = document.getElementById("hint");
alert(hint.firstElementChild.nodeName); // Outputs: SPAN
hint.firstElementChild.style.color = "blue";
</script>
Similarly, you can use the childNodes
property to access all child nodes of a given element, where the first child node is assigned index 0. Here's an example:
<div id="main">
<h1 id="title">My Heading</h1>
<p id="hint"><span>This is some text.</span></p>
</div>
<script>
var main = document.getElementById("main");
// First check that the element has child nodes
if(main.hasChildNodes()) {
var nodes = main.childNodes;
// Loop through node list and display node name
for(var i = 0; i < nodes.length; i++) {
alert(nodes[i].nodeName);
}
}
</script>
The childNodes
returns all child nodes, including non-element nodes like text and comment nodes. To get a collection of only elements, use children
property instead.
<div id="main">
<h1 id="title">My Heading</h1>
<p id="hint"><span>This is some text.</span></p>
</div>
<script>
var main = document.getElementById("main");
// First check that the element has child nodes
if(main.hasChildNodes()) {
var nodes = main.children;
// Loop through node list and display node name
for(var i = 0; i < nodes.length; i++) {
alert(nodes[i].nodeName);
}
}
</script>
1666209000
UILabel drop-in replacement supporting Hashtags (#), Mentions (@), URLs (http://), Emails and custom regex patterns, written in Swift
UILabel
drop-in replacementAdd the following to your Cartfile
and follow these instructions
github "optonaut/ActiveLabel.swift"
CocoaPods 0.36 adds supports for Swift and embedded frameworks. To integrate ActiveLabel into your project add the following to your Podfile
:
platform :ios, '10.0'
use_frameworks!
pod 'ActiveLabel'
import ActiveLabel
let label = ActiveLabel()
label.numberOfLines = 0
label.enabledTypes = [.mention, .hashtag, .url, .email]
label.text = "This is a post with #hashtags and a @userhandle."
label.textColor = .black
label.handleHashtagTap { hashtag in
print("Success. You just tapped the \(hashtag) hashtag")
}
let customType = ActiveType.custom(pattern: "\\swith\\b") //Regex that looks for "with"
label.enabledTypes = [.mention, .hashtag, .url, .email, customType]
label.text = "This is a post with #hashtags and a @userhandle."
label.customColor[customType] = UIColor.purple
label.customSelectedColor[customType] = UIColor.green
label.handleCustomTap(for: customType) { element in
print("Custom type tapped: \(element)")
}
By default, an ActiveLabel instance has the following configuration
label.enabledTypes = [.mention, .hashtag, .url, .email]
But feel free to enable/disable to fit your requirements
When using ActiveLabel, it is recommended to use the customize(block:)
method to customize it. The reason is that ActiveLabel is reacting to each property that you set. So if you set 3 properties, the textContainer is refreshed 3 times.
When using customize(block:)
, you can group all the customizations on the label, that way ActiveLabel is only going to refresh the textContainer once.
Example:
label.customize { label in
label.text = "This is a post with #multiple #hashtags and a @userhandle."
label.textColor = UIColor(red: 102.0/255, green: 117.0/255, blue: 127.0/255, alpha: 1)
label.hashtagColor = UIColor(red: 85.0/255, green: 172.0/255, blue: 238.0/255, alpha: 1)
label.mentionColor = UIColor(red: 238.0/255, green: 85.0/255, blue: 96.0/255, alpha: 1)
label.URLColor = UIColor(red: 85.0/255, green: 238.0/255, blue: 151.0/255, alpha: 1)
label.handleMentionTap { self.alert("Mention", message: $0) }
label.handleHashtagTap { self.alert("Hashtag", message: $0) }
label.handleURLTap { self.alert("URL", message: $0.absoluteString) }
}
You have the possiblity to set the maximum lenght a url can have;
label.urlMaximumLength = 30
From now on, a url that's bigger than that, will be trimmed.
https://afancyurl.com/whatever
-> https://afancyurl.com/wh...
mentionColor: UIColor = .blueColor()
mentionSelectedColor: UIColor?
hashtagColor: UIColor = .blueColor()
hashtagSelectedColor: UIColor?
URLColor: UIColor = .blueColor()
URLSelectedColor: UIColor?
customColor: [ActiveType : UIColor]
customSelectedColor: [ActiveType : UIColor]
lineSpacing: Float?
handleMentionTap: (String) -> ()
label.handleMentionTap { userHandle in print("\(userHandle) tapped") }
handleHashtagTap: (String) -> ()
label.handleHashtagTap { hashtag in print("\(hashtag) tapped") }
handleURLTap: (NSURL) -> ()
label.handleURLTap { url in UIApplication.shared.openURL(url) }
handleEmailTap: (String) -> ()
label.handleEmailTap { email in print("\(email) tapped") }
handleCustomTap(for type: ActiveType, handler: (String) -> ())
label.handleCustomTap(for: customType) { element in print("\(element) tapped") }
filterHashtag: (String) -> Bool
label.filterHashtag { hashtag in validHashtags.contains(hashtag) }
filterMention: (String) -> Bool
label.filterMention { mention in validMentions.contains(mention) }
Before writing ActiveLabel
we've tried a lot of the following alternatives but weren't quite satisfied with the quality level or ease of usage, so we decided to contribute our own solution.
Author: optonaut
Source Code: https://github.com/optonaut/ActiveLabel.swift
License: MIT license