Increase the font size of emoji characters in a UITextView in iOS 5.x

萝らか妹 提交于 2019-11-30 13:36:48

Have you tried setting the UITextView's font to AppleColorEmoji as well? On iOS, it seems that AppleColorEmoji is the only font that will draw scaled-up emoji. Use any other font, and the emoji never get larger than about 20x20 pixels, as you've noticed.

I did my tests using this handy free app called Fonts!, which is a nice way of getting quick feedback on the actual device itself.

I note that the Game Center app seems to be able to mix an interesting font with scaled-up emoji, so clearly it IS possible to do better than the (rather pedestrian) emoji font! I don't know whether this is something special in its code, though, or something special about the font it uses, which looks like a custom one.

You can scale emojis up with ANY font is you set the UITextViews contentScaleFactor and then scale the text field using a CGTransform. (You can even scale them up bigger (with high resolution) than AppleColorEmoji allows you to go by default.

float scaleFactor = 2.0f;
float resolutionFactor = 2.0f;

CGPoint tempCenter = theTextView.center;

theTextView.contentScaleFactor *= resolutionFactor;
theTextView.layer.contentsScale *= resolutionFactor;


for (UIView *subview in [theTextView subviews]) {
    subview.contentScaleFactor *= resolutionFactor;
    subview.layer.contentsScale *= resolutionFactor;
}

theTextView.transform = CGAffineTransformScale(CGAffineTransformIdentity, scaleFactor, scaleFactor);

theTextView.center = tempCenter;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!