如何在UILabel周围绘制边框? [英] How to draw border around a UILabel?

查看:165
本文介绍了如何在UILabel周围绘制边框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

UILabel有没有办法在自己周围画一个边框?

Is there a way for UILabel to draw a border around itself? This is useful for me to debug the text placement and to see the placement and how big the label actually is.

推荐答案

这可以帮助我调试文本展示位置和查看展示位置以及标签的实际大小。通过其底层CALayer属性设置标签的边框:

You can set label's border via its underlying CALayer property:

#import <QuartzCore/QuartzCore.h>

myLabel.layer.borderColor = [UIColor greenColor].CGColor;
myLabel.layer.borderWidth = 3.0;

这篇关于如何在UILabel周围绘制边框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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