回答
是的。使用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. WebGL發光效果
- 3. UISegmentedControl發光效果
- 4. 發光效果對PNG的脈動發光效果
- 5. 製作發光效果字體
- 6. WPF內部發光效果
- 7. UITextView中的發光效果
- 8. 邊界外發光效果
- 9. 圍繞NSView發光效果
- 10. Flex發光效果定製
- 11. Directx 11 HLSL發光效果
- 12. 如何在ie(7+)中實現文字發光效果?
- 13. 在iOS上創建發光文字效果
- 14. iphone遊戲的燈光效果與cocos2d
- 15. iPhone的光澤效果xcode 4.1
- 16. Google文檔光標效果
- 17. 如何在iPhone中獲得石英發光效果?
- 18. 按鈕的內部發光效果
- 19. WPF中的內部發光效果
- 20. iOS/GLES2:如何實現發光效果
- 21. 箱陰影發光效果即
- 22. WebGL在線上添加發光效果
- 23. 向圓圈添加發光效果
- 24. 如何隱藏發光效果?
- 25. android動畫發光效果對imageview
- 26. Android - 在畫布上發光效果
- 27. 禁用gtkbutton的發光效果
- 28. TextBlock發光效果內部按鈕
- 29. 發光效果在iPad的矩形
- 30. HTML5畫布上的發光效果?
很好的問題。我想要做確切的事情。 – Raptor
你應該接受@ andrewgleave的答案,因爲它效果很好! – msgambel