透明字体如何设置?
2015-12-20 19:47
274 查看
有时会在一些APP上看到透明字体, 感觉非常漂亮, 那么透明字体如何设置呢?
思路: 能显示字体, 当然是用label, 那么接下来我们自定义label–> EJLabel, 使用drawRect方法将透明字体画上去:
接下来切换到要显示透明字体的视图控制器中:
色彩搭配有点丑 -J-
思路: 能显示字体, 当然是用label, 那么接下来我们自定义label–> EJLabel, 使用drawRect方法将透明字体画上去:
- (void)drawRect:(CGRect)rect{ CGContextRef ctx = UIGraphicsGetCurrentContext(); CGRect viewBounds = self.bounds; CGContextTranslateCTM(ctx, 0, viewBounds.size.height); CGContextScaleCTM(ctx, 1, -1); CGContextSetBlendMode(ctx, kCGBlendModeCopy); CGContextSetRGBFillColor(ctx, 1.0, 1.0, 1.0, 0.0); CGContextSetLineWidth(ctx, 2.0); CGContextSelectFont(ctx, "Helvetica", 17.0, kCGEncodingMacRoman); CGContextSetCharacterSpacing(ctx, 1.7); CGContextSetTextDrawingMode(ctx, kCGTextFill); CGContextShowTextAtPoint(ctx, 0, 50, "Paradise", 8); }
接下来切换到要显示透明字体的视图控制器中:
- (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor greenColor]; EJLabel *label = [[EJLabel alloc]initWithFrame:CGRectMake(100, 100, 100, 100)]; label.backgroundColor = [UIColor orangeColor]; label.alpha = 0.5; [self.view addSubview:view]; }
色彩搭配有点丑 -J-
相关文章推荐
- 如何调用本地相册、相机
- GYM 100796C Minimax Tree
- java(十)return
- Python创建中文目录
- JavaScript设计模式--中介者模式
- Snackbar 的简单使用
- UESTC 482 Charitable Exchange(四川省赛B题)
- CCF CSP 201509-4 树的直径 相关解题方法和网址
- java异常处理及定义
- 数据结构基础(一)线性表
- 校内赛总结
- 如何更改Linux中默认的openjdk为自己安装的JDK
- 当自己的Ubuntu遇到卡死的时候
- JMockit简单使用(二)
- Linux网络编程笔记
- unity 常用优化技术
- zstuoj (浙理工) 孙壕请一盘青岛大虾呗
- Autolayout(VFL)
- anr,多线程,handler
- Google java编程风格指南