ストリーミングはほとんどのブラウザと
Developerアプリで視聴できます。
-
Genmojiでアプリに表情を追加
アプリ内でのGenmojiの使い方に精彩を与える方法を習得しましょう。Genmojiを含むテキストをレンダリング、格納、やり取りする方法を概説します。カスタムテキストエンジンを使用するアプリにGenmojiのサポートを追加する手法もご紹介します。
関連する章
- 0:00 - Introduction
- 0:37 - Express yourself
- 1:17 - Emoji enhancements
- 2:17 - NSAdaptiveImageGlyph
- 3:15 - Adopting in your app
- 8:01 - Compatibility
- 9:10 - Advanced usage
- 10:33 - Wrap-up
リソース
関連ビデオ
WWDC24
-
ダウンロードArray
-
-
3:30 - Enable support for NSAdaptiveImageGlyph in a UITextView
let textView = UITextView() textView.supportsAdaptiveImageGlyph = true
-
4:41 - Read and write attributed string for serialization
// Extract contents of text view as an attributed string let textContents = textView.textStorage // Serialize as data for storage or transport let rtfData = try textContents.data(from: NSRange(location: 0, length: textContents.length), documentAttributes: [.documentType: NSAttributedString.DocumentType.rtfd]) // Create attributed string from serialized data let textFromData = try NSAttributedString(data: rtfData, documentAttributes: nil) // Set on text view textView.textStorage.setAttributedString(textFromData)
-
6:08 - Decompose and recompose an attributed string
// Decompose an attributed string func decomposeAttributedString(_ attrStr: NSAttributedString) -> (String, [(NSRange, String)], [String: Data]) { let string = attrStr.string var imageRanges: [(NSRange, String)] = [] var imageData: [String: Data] = [:] attrStr.enumerateAttribute(.adaptiveImageGlyph, in: NSMakeRange(0, attrStr.length)) { (value, range, stop) in if let glyph = value as? NSAdaptiveImageGlyph { let id = glyph.contentIdentifier imageRanges.append((range, id)) if imageData[id] == nil { imageData[id] = glyph.imageContent } } } return (string, imageRanges, imageData) } // Recompose an attributed string func recomposeAttributedString(string: String, imageRanges: [(NSRange, String)], imageData: [String: Data]) -> NSAttributedString { let attrStr: NSMutableAttributedString = .init(string: string) var images: [String: NSAdaptiveImageGlyph] = [:] for (id, data) in imageData { images[id] = NSAdaptiveImageGlyph(imageContent: data) } for (range, id) in imageRanges { attrStr.addAttribute(.adaptiveImageGlyph, value: images[id]!, range: range) } return attrStr }
-
6:30 - Convert NSAttributedString to HTML
// Converting NSAttributedString to HTML let htmlData = try textContent.data(from: NSRange(location: 0, length: textContent.length), documentAttributes: [.documentType: NSAttributedString.DocumentType.html])
-
7:33 - Support Genmoji in communication notifications
func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) { ... let message: NSAttributedString = _myAttributedMessageStringWithGlyph let context = UNNotificationAttributedMessageContext(sendMessageIntent: sendMessageIntent, attributedContent: _message) do { let messageContent = try request.content.updating(from: context) contentHandler(messageContent) } catch { // Handle error } }
-
9:45 - Render NSAdaptiveImageGlyph in custom typesetting solution
// Find typographic bounds for image in NSAdaptiveImageGlyph let provider = adaptiveImageGlyph let bounds = CTFontGetTypographicBoundsForAdaptiveImageProvider(font, provider) // Draw it at the typographic origin point on the baseline CTFontDrawImageFromAdaptiveImageProviderAtPoint(font, provider, point, context)
-
-
特定のトピックをお探しの場合は、上にトピックを入力すると、関連するトピックにすばやく移動できます。
クエリの送信中にエラーが発生しました。インターネット接続を確認して、もう一度お試しください。