Emojica allows you to replace the standard emoji in your iOS apps with
twemojis. Works on UILabel
and UITextView
.
Just follow the instructions below, import your custom image set, and you're ready to go.
- Compatible with all iOS 14 emoji
- Convert input directly on
textViewDidChange(_:)
- Revert converted strings to their original representation
- Xcode 11
- iOS 13.0+
- Lower versions haven't been tested, although the framework may run without issues on a lower version.
- Swift 5
- Using the framework in an Objective-C project may require some modifications to the source. Support for Objective-C will possibly be added at some point in the future.
- Add the pod to your
Podfile
:
target '...' do
pod 'Emojica', :git => 'https://github.com/aboard-io/emojica.git'
end
- Navigate into your project directory and install/update:
$ cd /Path/To/Your/Project/ && pod install
- Clone the repository, and drag
Emojica.xcodeproj
into your project hierarchy in Xcode. - Select your project, then select your application's target under Targets.
- Under the General tab, click the + under Embedded Binaries.
- Select
Emojica.frameworkiOS
and finish by pressing Add.
If Xcode gives you a
No such module 'Emojica'
compiler error at yourimport
statement, just build your application (or the framework) once. Also, each time you Clean (⇧⌘K) the project Xcode will give you the same error, and the solution is the same.
import Emojica
let emojica = Emojica()
// Creates an instance with a font.
let emojica = Emojica(font: UIFont.systemFont(ofSize: 17.0))
-
Set font:
emojica.font = UIFont.systemFont(ofSize: 17.0)
If no font is set, the system font is used.
-
Set size:
emojica.pointSize = 17.0
If you're satisfied with the default font, you can just set the size.
The value for pointSize
is 17.0 by default.
- Enable emoji to be reverted:
NOTE: Keep the instance non-revertible if the original strings aren't needed after conversion.
emojica.revertible = true
Enables strings with custom emoji to be reverted to original state.
let sample: String = "Sample text 😎"
let converted: NSAttributedString = emojica.convert(string: sample)
NOTE: The instance must have
revertible
set totrue
.
let reverted: String = emojica.revert(attributedString: converted)
let textView = UITextView()
...
let flag: String = "🇫🇮 "
textView.attributedText = emojica.convert(string: flag)
You can directly convert text input by implementing the UITextViewDelegate
method textViewDidChange(_:)
and passing the changed UITextView
to the
Emojica method by the same name:
func textViewDidChange(_ textView: UITextView) {
emojica.textViewDidChange(textView)
}
The example EmojicaExample.xcodeproj
is set up but does not contain
images. To test the project, add your emoji images to the Images
group and
Run.
Emojica is released under the Apache License 2.0.