在iOS上创建发光文本效果 [英] Create glowing text effect on iOS

查看:416
本文介绍了在iOS上创建发光文本效果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们目前正在构建一个iPhone应用程序,并希望文本具有发光效果以适应逼真的UI设计。

We're currently building an iPhone app and would like the text to have a glowing effect to fit in with the realistic UI design.

这就是我们'重新努力实现。

Here is what we're trying to achieve.

我们正在努力创造内部发光效果,所以任何帮助都会受到赞赏。

We are struggling to create the inner glow effect at the moment so any help would be appreciated.

在Photoshop中这个文字有

In photoshop this text has


  • 颜色为#98c1c1

  • 外发光:#ffffff,屏幕混合模式,30%不透明度,5px尺寸。

  • 内部发光:#c79d85,颜色减淡混合模式,70%不透明度,5px尺寸。

谢谢,
马克。

Thanks, Mark.

推荐答案

要设置文本颜色为#98c1c1的按钮,请使用:

To set up the button with the text colored #98c1c1, use:

UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(100, 100, 100, 60)];
label.textColor = [UIColor colorWithRed:((float)152/255) green:((float) 193/255) blue:((float) 193/255) alpha:1.0f];

我使用Photoshop查找#98c1c1的RGB组件,结果为R:152 G:193 B:193。并且 colorWithRed:绿色:蓝色:alpha:采用0到1之间的标准化值,这就是为什么我将RGB值设置为超过255.

I used Photoshop to find RGB components of #98c1c1, which ended up being R:152 G:193 B:193. And colorWithRed:green:blue:alpha: takes a normalized value between 0 and 1, and that's why I made it the RGB value over 255.

对于外部发光,请使用:

For the outer glow, use:

label.layer.shadowColor = [UIColor whiteColor].CGColor;
label.layer.shadowOffset = CGSizeMake(0.0, 0.0);    
label.layer.shadowRadius = 10.0;
label.layer.shadowOpacity = 0.3;
label.layer.masksToBounds = NO;

您希望不透明度为30%,阴影颜色为#ffffff(白色)。这就是 label.layer.shadowOpacity 设置为0.3(30%)和 label.layer.shadowColor 设置的原因白色。

You want the opacity to be 30% and the shadow color #ffffff (white). That is why label.layer.shadowOpacity is set to 0.3 (30%) and label.layer.shadowColor is set to white.

我不太清楚如何实现内部发光,但你可能会创建一个复制文本的方法,但会缩小字体并使中心变小新文本,创造内在发光的效果。记得导入< Quartzcore / Quartzcore.h>

I'm not quite sure about how to implement the inner glow, but you could possibly create a method that duplicates the text but makes the font smaller and centers the new text, to create the effect of an inner glow. Remember to import <Quartzcore/Quartzcore.h>!

这篇关于在iOS上创建发光文本效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆