回答
是的。使用beginAnimation ... commitAnimation,并使用alpha值来使ULabel变亮或变暗。确保UILabel alpha的默认值从0.85开始,然后变亮为1.0,然后变暗为0.75,当所有操作完成后,返回0.85。
还有其他方法可以做到这一点,比如在灰色或黑色的标签顶部有另一个视图,并且您使用相同的begin ... commitAnimation将alpha从0改为0.20左右。
阅读问题请 – SeniorShizzle
他只是回答动画部分,所以这个答案是可以的。 –
有很多方法可以做到这一点,质量不同。一种方法是对UILabel进行子类化,并在drawRect方法中的coregraphics中实现某种渐变效果。
你也可以玩文字阴影(改变颜色和alpha),看看你是否能想出一个体面的光晕。
最简单的方法可能是在photoshop中制作一个透明的辉光轮廓图像,并将其放在文本后面,然后像mahboudz建议的那样...使用coreanimation淡入淡出图像。
我已经发布了一些示例代码,其子类UILabel,并使您能够应用发光和柔和的阴影文本。
http://www.redrobotstudios.com/blog/2010/04/29/create-glow-soft-shadow-text-on-iphone/
由于3.2你有在SDK阴影的直接支持。
label.layer.shadowColor = [label.textColor CGColor];
label.layer.shadowOffset = CGSizeMake(0.0, 0.0);
播放与参数:
label.layer.shadowRadius = 3.0;
label.layer.shadowOpacity = 0.5;
,避免阴影被修剪由标签bouds:
label.layer.masksToBounds = NO;
不要忘记
#include <Quartzcore/Quartzcore.h>
和链接反对QuartzCore
或CoreGraphics
框架(感谢评论者指出了这一点)。
- (UILabel *) setUpGlowLabelWithFrame: (CGRect) frame fontSize: (int)fontSize {
UILabel* label = [[UILabel alloc] initWithFrame:frame];
label.backgroundColor = [UIColor clearColor];
label.font = [UIFont boldSystemFontOfSize:fontSize];
label.textColor = [UIColor whiteColor];
label.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin;
label.textAlignment = UITextAlignmentCenter;
label.layer.shadowColor = [label.textColor CGColor];
label.layer.shadowOffset = CGSizeMake(0.0, 0.0);
label.layer.masksToBounds = NO;
label.layer.shadowRadius = 0.5f;
label.layer.shadowOpacity = 0.95;
label.numberOfLines = 2;
label.tag = 20;
return label;
}
使用此功能时,我会获得发光效果。
希望它有帮助。
快乐编码:)
- 1. iPhone界面发光效果问题
- 2. UISegmentedControl发光效果
- 3. WebGL发光效果
- 4. 发光效果对PNG的脉动发光效果
- 5. 制作发光效果字体
- 6. Flex发光效果定制
- 7. 对MouseEnter发光效果WPF
- 8. UITextView中的发光效果
- 9. DirectX 9 HLSL发光效果
- 10. 发光风格效果
- 11. WPF内部发光效果
- 12. 围绕NSView发光效果
- 13. 绽放和发光效果
- 14. 边界外发光效果
- 15. Directx 11 HLSL发光效果
- 16. iPhone的光泽效果xcode 4.1
- 17. iphone游戏的灯光效果与cocos2d
- 18. 在iOS上创建发光文字效果
- 19. 如何在ie(7+)中实现文字发光效果?
- 20. 使用CSS的文字外部发光效果
- 21. 如何在iPhone中获得石英发光效果?
- 22. Google文档光标效果
- 23. 光泽效果
- 24. iOS/GLES2:如何实现发光效果
- 25. 箱阴影发光效果即
- 26. 按钮的内部发光效果
- 27. 向圆圈添加发光效果
- 28. Android - 在画布上发光效果
- 29. WPF发光效果没有BitmapEffects
- 30. WinRT中TextBlock的外部发光效果
很好的问题。我想要做确切的事情。 – Raptor
你应该接受@ andrewgleave的答案,因为它效果很好! – msgambel