[英]UILabel blur only text
I'm trying to blur the text of a label that I create programmatically, I've been able to apply the blur, but only to the label itself, leaving the text readable and blurying only the background behind the label. 我试图模糊以编程方式创建的标签的文本,我已经能够将模糊应用到标签本身,而仅将文本应用于标签,使文本可读并且仅模糊标签后面的背景。
Is there any way to blur only the text? 有什么方法可以只模糊文本吗?
Thanks in advance. 提前致谢。
EDIT: 编辑:
Heres my code till now: 到目前为止,这是我的代码:
UILabel *lblVericalName =
[[UILabel alloc]initWithFrame:CGRectMake(-95,
_viewVerticalStick.frame.size.height-120,
200,
20)];
lblVericalName.tag = [tarefaDiaArray.idTarefaDia integerValue];
lblVericalName.text = tarefaDiaArray.nomeTarefa;
lblVericalName.transform=CGAffineTransformMakeRotation( M_PI+89.55 );
UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
UIVisualEffectView *blurEffectView =
[[UIVisualEffectView alloc] initWithEffect:blurEffect];
blurEffectView.frame = lblVericalName.bounds;
blurEffectView.autoresizingMask =
UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[viewStickBackground addSubview:lblVericalName];
if ([tarefaDiaArray.tarefaPremium intValue] ==1) {
//[viewStickBackground addSubview:blurEffectView];
[lblVericalName addSubview:blurEffectView];
}
EDIT 2: 编辑2:
UPDATE 更新
I've made some progress, now I have this: 我已经取得了一些进展,现在有了这个:
and I need to make it look like this: 我需要使它看起来像这样:
here is the code that i'm using: 这是我正在使用的代码:
lblNomeVertical.textColor = [UIColor colorWithRed:0.494 green:0.494 blue:0.494 alpha:0.8]; lblNomeVertical.textColor = [UIColor colorWithRed:0.494绿色:0.494蓝色:0.494 alpha:0.8];
lblNomeVertical.layer.shadowOffset = CGSizeMake(1, 1.1);
lblNomeVertical.layer.shadowColor = [UIColor colorWithRed:0.827 green:0.827 blue:0.827 alpha:1].CGColor;
lblNomeVertical.layer.shadowRadius = 1.0;
lblNomeVertical.layer.shadowOpacity = 1;
Instead of using a label, use a drawing. 代替使用标签,而使用图形。 In code, draw the text yourself and blur it yourself (eg with a box blur or a gaussian blur CIFilter). 在代码中,自己绘制文本并自己对其进行模糊处理(例如,使用框模糊处理或高斯模糊处理CIFilter)。 Now just place that drawing in front of your background. 现在,只需将该图形放在背景前面即可。 In that way, I was able to achieve this, which seems to be the sort of thing you are after (of course it can be more blurry if you want): 这样,我就能实现这一目标,这似乎就是您所追求的(当然,如果您愿意,它可能会更加模糊):
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.