-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimageAndTextAttributedString.codesnippet
46 lines (43 loc) · 1.8 KB
/
imageAndTextAttributedString.codesnippet
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDECodeSnippetCompletionPrefix</key>
<string>imageAndTextAttributedString</string>
<key>IDECodeSnippetCompletionScopes</key>
<array>
<string>All</string>
</array>
<key>IDECodeSnippetContents</key>
<string>
static private func constructAttributedString(text: String,
textColor: UIColor,
font: UIFont,
image: UIImage,
imageSize: CGSize) -> NSAttributedString {
let attributedString = NSMutableAttributedString()
let attachment = NSTextAttachment()
attachment.image = image
let offset = font.descender + (font.lineHeight - imageSize.height) / 2
attachment.bounds = CGRect(x: 0, y: offset, width: imageSize.width, height: imageSize.height)
let attachmentAttributedString = NSAttributedString(attachment: attachment)
attributedString.append(attachmentAttributedString)
let textAttributedString = NSMutableAttributedString(string: text)
textAttributedString.yy_color = textColor
attributedString.append(textAttributedString)
return attributedString
}</string>
<key>IDECodeSnippetIdentifier</key>
<string>F336B3EE-BC5F-400F-A898-6B9296901995</string>
<key>IDECodeSnippetLanguage</key>
<string>Xcode.SourceCodeLanguage.Swift</string>
<key>IDECodeSnippetSummary</key>
<string>imageAndTextAttributedString</string>
<key>IDECodeSnippetTitle</key>
<string>imageAndTextAttributedString</string>
<key>IDECodeSnippetUserSnippet</key>
<true/>
<key>IDECodeSnippetVersion</key>
<integer>2</integer>
</dict>
</plist>